summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2005-07-21 06:30:58 +0200
committerlpsolit%gmail.com <>2005-07-21 06:30:58 +0200
commit69ec0a28fd6b83f7001027dbc60ffa6b8e6b27bb (patch)
tree06b27ec88a90374827aa9d774e865f3917fef177 /Bugzilla
parentb8a33eb39a2fb1e994f84dc013440375b9f45dcc (diff)
downloadbugzilla-69ec0a28fd6b83f7001027dbc60ffa6b8e6b27bb.tar.gz
bugzilla-69ec0a28fd6b83f7001027dbc60ffa6b8e6b27bb.tar.xz
Bug 301458: Move url_decode out of CGI.pl - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat a=myk
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Util.pm28
1 files changed, 28 insertions, 0 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index 256be5c31..6422984c2 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -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