login/edit: prepare input restriction for user names
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 19 Jun 2018 17:02:52 +0000 (19:02 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 19 Jun 2018 18:57:08 +0000 (20:57 +0200)
Indicate validity even though it cannot be altered yet.

login/edit.php

index 017a56221a5c9765c99915b840d3a977a9c632ac..4002cb989098d65db18a1f6c225c283050c0aecd 100644 (file)
@@ -45,7 +45,12 @@ foreach ($cols as $col => &$colconf) {
 }
 
 $cols = [
-       'login' => ['label' => 'login', 'value' => $user['name'], 'target' => NULL],
+       'login' => [
+               'label' => 'login',
+               'value' => $user['name'],
+               'target' => NULL,
+               'pattern' => "[a-z0-9-]+",
+       ],
 ] + $cols;
 
 if (isset($user['pass'])) {
@@ -159,6 +164,7 @@ foreach ($cols as $col => &$colconf) {
                        'value'       => htmlspecialchars(@$colconf['value']),
                        'placeholder' => "Niet ingesteld",
                        'readonly'    => empty($colconf['target']),
+                       'pattern'     => @$colconf['pattern'] ?: FALSE,
                ];
                if (@$colconf['type'] == 'file') {
                        $attrs['accept'] = "image/jpeg";