]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 301458: Move url_decode out of CGI.pl - Patch by Frédéric Buclin <LpSolit@gmail...
authorlpsolit%gmail.com <>
Thu, 21 Jul 2005 04:30:58 +0000 (04:30 +0000)
committerlpsolit%gmail.com <>
Thu, 21 Jul 2005 04:30:58 +0000 (04:30 +0000)
Bugzilla/Util.pm
CGI.pl
query.cgi

index 256be5c31fdb7021242a636492e695d6e97bdf28..6422984c2643af79488888015aae3eb9aa4930ec 100644 (file)
@@ -131,6 +131,13 @@ sub xml_quote {
     return $var;
 }
 
+sub url_decode {
+    my ($todecode) = (@_);
+    $todecode =~ tr/+/ /;       # pluses become spaces
+    $todecode =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
+    return $todecode;
+}
+
 sub i_am_cgi () {
     # I use SERVER_SOFTWARE because it's required to be
     # defined for all requests in the CGI spec.
@@ -391,6 +398,9 @@ Bugzilla::Util - Generic utility functions for bugzilla
   value_quote($var);
   xml_quote($var);
 
+  # Functions for decoding
+  $rv = url_decode($var);
+  
   # Functions that tell you about your environment
   my $is_cgi = i_am_cgi();
 
@@ -416,6 +426,9 @@ Bugzilla::Util - Generic utility functions for bugzilla
   # Cryptographic Functions
   $crypted_password = bz_crypt($password);
 
+  # Validation Functions
+  check_email_syntax($email);
+
 =head1 DESCRIPTION
 
 This package contains various utility functions which do not belong anywhere
@@ -498,6 +511,10 @@ This is similar to C<html_quote>, except that ' is escaped to &apos;. This
 is kept separate from html_quote partly for compatibility with previous code
 (for &apos;) and partly for future handling of non-ASCII characters.
 
+=item C<url_decode($val)>
+
+Converts the %xx encoding from the given URL back to its original form.
+
 =item C<i_am_cgi()>
 
 Tells you whether or not you are being run as a CGI script in a web
@@ -638,3 +655,14 @@ characters of the password to anyone who views the encrypted version.
 =end undocumented
 
 =back
+
+=head2 Validation
+
+=over 4
+
+=item C<check_email_syntax($email)>
+
+Do a syntax checking for a legal email address. An error is thrown
+if the validation fails.
+
+=back
diff --git a/CGI.pl b/CGI.pl
index a5f369f81a2551bcf4f8d30dc2ca60fc29fa7881..9c65efdf22d49b80e3bd7914ba90b1985f891920 100644 (file)
--- a/CGI.pl
+++ b/CGI.pl
@@ -55,14 +55,6 @@ use vars qw($template $vars);
 # Implementations of several of the below were blatently stolen from CGI.pm,
 # by Lincoln D. Stein.
 
-# Get rid of all the %xx encoding and the like from the given URL.
-sub url_decode {
-    my ($todecode) = (@_);
-    $todecode =~ tr/+/ /;       # pluses become spaces
-    $todecode =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
-    return $todecode;
-}
-
 # check and see if a given field exists, is non-empty, and is set to a 
 # legal value.  assume a browser bug and abort appropriately if not.
 # if $legalsRef is not passed, just check to make sure the value exists and 
index fa4a791f8deccbc2a7c18c8dbb46b8d722f574d1..ff04c15a0cd58603add2f41b1aeffa32765ea8df 100755 (executable)
--- a/query.cgi
+++ b/query.cgi
@@ -33,6 +33,7 @@ require "CGI.pl";
 use Bugzilla::Constants;
 use Bugzilla::Search;
 use Bugzilla::User;
+use Bugzilla::Util;
 
 use vars qw(
     @CheckOptionValues
@@ -165,7 +166,7 @@ sub PrefillForm {
         my $name = $el[0];
         my $value;
         if ($#el > 0) {
-            $value = url_decode($el[1]);
+            $value = Bugzilla::Util::url_decode($el[1]);
         } else {
             $value = "";
         }