From af70b477321f1183f154e0c6d19e4e7db0bef7c6 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 6 Jun 2023 20:30:57 +0100 Subject: [PATCH] Fix quiz question to use standard machinery --- bcp5-registry.pl | 8 +++----- template.html | 8 ++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) 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:@@@ -- 2.30.2