From: Ian Jackson Date: Tue, 6 Jun 2023 19:30:57 +0000 (+0100) Subject: Fix quiz question to use standard machinery X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=af70b477321f1183f154e0c6d19e4e7db0bef7c6;p=bcp5-registry.git Fix quiz question to use standard machinery --- diff --git a/bcp5-registry.pl b/bcp5-registry.pl index a1542e9..b0c7690 100755 --- a/bcp5-registry.pl +++ b/bcp5-registry.pl @@ -206,11 +206,9 @@ if ($invokestyle eq 'maintain') { } elsif (length $in{'mailpasswd'}) { if (! $in{'quiz'}) { - print "Please answer the quiz question."; - exit 0; + finish_error('noquiz'); } elsif ($in{'quiz'} !~ m{^(?:bcp5|rfc1918)$}i) { - print "Wrong answer to the quiz question."; - exit 0; + finish_error('badquiz'); } read_database(); @@ -437,7 +435,7 @@ sub finish_error ($) { my ($type) = @_; my ($t, $esel, $f); foreach $t (qw(noemail nonet noname nocontact badsize wrongsize badnet wrongnet - nopassword badpassword notfound badchar)) { + nopassword badpassword notfound badchar noquiz badquiz)) { $esel= "error_$t"; $$esel= 0; $f=1 if $type eq $t; diff --git a/template.html b/template.html index 7fadf1b..a6236c0 100644 --- a/template.html +++ b/template.html @@ -219,6 +219,14 @@ You must provide a network name for the database. The name, contact or email address you specified contains illegal character(s). @@@endif:@@@ +@@@if:error_noquiz@@@ +Please answer the quiz question, to prove you're not a robot. +@@@endif:@@@ + +@@@if:error_badquiz@@@ +Wrong answer to the quiz question. +@@@endif:@@@ + @@@endif:@@@