fix: role form limits the name input to the 64 characters its column stores (#8385)

This commit is contained in:
Harsh Singh authored and GitHub committed 2026-11-26 18:59:27 -05:00
1 parent dfe0db5cf1
commit 92e8ce97f6
2 files changed
+18 -1

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
<?php
// User_Roles.Name is varchar(64), but the role form let a browser submit a longer
// name, which the save then failed on. Reads the view as text (it needs a full
// web environment to run) and checks the Name input carries the column length.
//
// Run as: php tests/php/test_role_name_maxlength.php [repo root]
$root = isset($argv[1]) ? rtrim($argv[1], '/') : realpath(__DIR__.'/../..');
$file = 'web/skins/classic/views/role.php';
$text = file_get_contents($root.'/'.$file);
$text = preg_replace('/<\?(?:php\b|=).*?\?>/s', 'PHP', $text);
preg_match_all('/<input\b[^>]*name="role\[Name\]"[^>]*>/i', $text, $m);
$ok = count($m[0]) === 1 && preg_match('/\bmaxlength\s*=\s*["\']?64\b/', $m[0][0]);
echo ($ok ? 'ok' : 'FAIL')." - role name input has maxlength 64\n";
echo $ok ? "\n1 passed, 0 failed\n" : "\n0 passed, 1 failed\n";
exit($ok ? 0 : 1);
+1 -1
View File
@@ -73,7 +73,7 @@ echo getNavBarHTML();
<tbody>
<tr>
<th scope="row"><?php echo translate('Name') ?></th>
<td><input type="text" class="form-control form-control-sm" name="role[Name]" placeholder="<?php echo translate('NewRole') ?>" value="<?php echo validHtmlStr($Role->Name()); ?>"/></td>
<td><input type="text" class="form-control form-control-sm" name="role[Name]" placeholder="<?php echo translate('NewRole') ?>" value="<?php echo validHtmlStr($Role->Name()); ?>" maxlength="64"/></td>
</tr>
<tr>
<th scope="row"><?php echo translate('Description') ?></th>