From 7bb05f06fa763bf360b14045f79d491102a0f501 Mon Sep 17 00:00:00 2001 From: "gerv%gerv.net" <> Date: Mon, 29 Apr 2002 04:57:08 +0000 Subject: Bug 140103 - various templatisations or cleanups in CGI.pl. Patch by gerv; r=justdave, bbaetz. --- CGI.pl | 146 ++++++---------------- template/en/default/bug/process/results.html.tmpl | 1 + 2 files changed, 39 insertions(+), 108 deletions(-) diff --git a/CGI.pl b/CGI.pl index c0e38c50a..979ffda0d 100644 --- a/CGI.pl +++ b/CGI.pl @@ -242,11 +242,9 @@ sub CheckFormFieldDefined (\%$) { $fieldname, # the fieldname to check ) = @_; - if ( !defined $formRef->{$fieldname} ) { - print "$fieldname was not defined; "; - print Param("browserbugmessage"); - PutFooter(); - exit 0; + if (!defined $formRef->{$fieldname}) { + ThrowCodeError("$fieldname was not defined; " . + Param("browserbugmessage")); } } @@ -489,22 +487,12 @@ sub CheckEmailSyntax { my ($addr) = (@_); my $match = Param('emailregexp'); if ($addr !~ /$match/ || $addr =~ /[\\\(\)<>&,;:"\[\] \t\r\n]/) { - print "Content-type: text/html\n\n"; - - # For security, escape HTML special characters. - $addr = html_quote($addr); - - PutHeader("Check e-mail syntax"); - print "The e-mail address you entered\n"; - print "($addr) didn't match our minimal\n"; - print "syntax checking for a legal email address.\n"; - print Param('emailregexpdesc') . "\n"; - print "It must also not contain any of these special characters: " . - "\\ ( ) & < > , ; : \" [ ] " . - "or any whitespace.\n"; - print "
Please click Back and try again.\n"; - PutFooter(); - exit; + ThrowUserError("The e-mail address you entered(" . + html_quote($addr) . ") didn't pass our syntax checking + for a legal email address. " . Param('emailregexpdesc') . + ' It must also not contain any of these special characters: + \ ( ) & < > , ; : " [ ], or any whitespace.', + "Check e-mail address syntax"); } } @@ -559,24 +547,17 @@ sub confirm_login { if ( defined $::FORM{"PleaseMailAPassword"} && !$userid ) { # Ensure the new login is valid if(!ValidateNewUser($enteredlogin)) { - DisplayError("Account Exists"); - exit; + ThrowUserError("That account already exists."); } my $password = InsertNewUser($enteredlogin, ""); - # There's a template for this - account_created.tmpl - but - # it's easier to wait to use it until templatisation has progressed - # further; we want to avoid sprinkling multiple copies of the - # template setup code everywhere - Gerv. - print "Content-Type: text/html\n\n"; - PutHeader("Account Created"); MailPassword($enteredlogin, $password); - print "The password for the e-mail address\n"; - print "$enteredlogin has been e-mailed to that address.\n"; - print "
When the e-mail arrives, you can click Back\n"; - print "and enter your password in the form there.\n"; - PutFooter(); - exit; + + $vars->{'login'} = $enteredlogin; + + print "Content-Type: text/html\n\n"; + $template->process("account/created.html.tmpl", $vars) + || ThrowTemplateError($template->error()); } # Otherwise, authenticate the user. @@ -755,14 +736,10 @@ Set-Cookie: Bugzilla_logincookie= ; path=$cookiepath; expires=Sun, 30-Jun-80 00: Content-type: text/html "; - PutHeader("Your account has been disabled"); - print $::disabledreason; - print "
-
|
-- | -$h2 - |
\n"; - print Param("shutdownhtml"); - exit; - } - } + ($vars->{'title'}, $vars->{'h1'}, $vars->{'h2'}, + $vars->{'extra'}, $vars->{'jscript'}) = (@_); + + $::template->process("global/header.html.tmpl", $::vars) + || ThrowTemplateError($::template->error()); } -# Putfooter echoes footerhtml and by default prints closing tags -# -# param -# dontclose (boolean): avoid sending -# -# Example: -# Putfooter(); # normal close -# Putfooter(1); # don't send closing tags sub PutFooter { - my ( $dontclose ) = @_; - print PerformSubsts(Param("footerhtml")); - print "\n