summaryrefslogtreecommitdiff
path: root/lib/VNWeb/Validation.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-10-02 20:07:53 +0200
committerYorhel <git@yorhel.nl>2019-10-02 20:07:55 +0200
commit2e9f6f1844131529f553de37eba0bca421a75f8b (patch)
treefb8b6fa55b3faae55c590d68be91f87855d94e9f /lib/VNWeb/Validation.pm
parent97b88b8a7f4623434430956504321a36e5ac24b7 (diff)
Improve client-side username validation and registration message
This uses negative lookahead in the username regex so that the DB identifiers can be matched with an HTML5 `pattern` attribute.
Diffstat (limited to 'lib/VNWeb/Validation.pm')
-rw-r--r--lib/VNWeb/Validation.pm2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/VNWeb/Validation.pm b/lib/VNWeb/Validation.pm
index 0ea635ad..5ddc1ac3 100644
--- a/lib/VNWeb/Validation.pm
+++ b/lib/VNWeb/Validation.pm
@@ -19,7 +19,7 @@ TUWF::set custom_validations => {
id => { uint => 1, max => 1<<40 },
editsum => { required => 1, length => [ 2, 5000 ] },
page => { uint => 1, min => 1, max => 1000, required => 0, default => 1 },
- username => { regex => qr/^[a-z0-9-]*$/, func => sub { $_[0] !~ /^-*[a-z][0-9]+-*$/ }, minlength => 2, maxlength => 15 },
+ username => { regex => qr/^(?!-*[a-z][0-9]+-*$)[a-z0-9-]*$/, minlength => 2, maxlength => 15 },
password => { length => [ 4, 500 ] },
};