Commit 69ec0a28 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 301458: Move url_decode out of CGI.pl - Patch by Frédéric Buclin…

Bug 301458: Move url_decode out of CGI.pl - Patch by Frédéric Buclin <LpSolit@gmail.com> r=mkanat a=myk
parent b8a33eb3
...@@ -131,6 +131,13 @@ sub xml_quote { ...@@ -131,6 +131,13 @@ sub xml_quote {
return $var; 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 () { sub i_am_cgi () {
# I use SERVER_SOFTWARE because it's required to be # I use SERVER_SOFTWARE because it's required to be
# defined for all requests in the CGI spec. # defined for all requests in the CGI spec.
...@@ -391,6 +398,9 @@ Bugzilla::Util - Generic utility functions for bugzilla ...@@ -391,6 +398,9 @@ Bugzilla::Util - Generic utility functions for bugzilla
value_quote($var); value_quote($var);
xml_quote($var); xml_quote($var);
# Functions for decoding
$rv = url_decode($var);
# Functions that tell you about your environment # Functions that tell you about your environment
my $is_cgi = i_am_cgi(); my $is_cgi = i_am_cgi();
...@@ -416,6 +426,9 @@ Bugzilla::Util - Generic utility functions for bugzilla ...@@ -416,6 +426,9 @@ Bugzilla::Util - Generic utility functions for bugzilla
# Cryptographic Functions # Cryptographic Functions
$crypted_password = bz_crypt($password); $crypted_password = bz_crypt($password);
# Validation Functions
check_email_syntax($email);
=head1 DESCRIPTION =head1 DESCRIPTION
This package contains various utility functions which do not belong anywhere 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 ...@@ -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 is kept separate from html_quote partly for compatibility with previous code
(for &apos;) and partly for future handling of non-ASCII characters. (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()> =item C<i_am_cgi()>
Tells you whether or not you are being run as a CGI script in a web 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. ...@@ -638,3 +655,14 @@ characters of the password to anyone who views the encrypted version.
=end undocumented =end undocumented
=back =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
...@@ -55,14 +55,6 @@ use vars qw($template $vars); ...@@ -55,14 +55,6 @@ use vars qw($template $vars);
# Implementations of several of the below were blatently stolen from CGI.pm, # Implementations of several of the below were blatently stolen from CGI.pm,
# by Lincoln D. Stein. # 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 # 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. # 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 # if $legalsRef is not passed, just check to make sure the value exists and
......
...@@ -33,6 +33,7 @@ require "CGI.pl"; ...@@ -33,6 +33,7 @@ require "CGI.pl";
use Bugzilla::Constants; use Bugzilla::Constants;
use Bugzilla::Search; use Bugzilla::Search;
use Bugzilla::User; use Bugzilla::User;
use Bugzilla::Util;
use vars qw( use vars qw(
@CheckOptionValues @CheckOptionValues
...@@ -165,7 +166,7 @@ sub PrefillForm { ...@@ -165,7 +166,7 @@ sub PrefillForm {
my $name = $el[0]; my $name = $el[0];
my $value; my $value;
if ($#el > 0) { if ($#el > 0) {
$value = url_decode($el[1]); $value = Bugzilla::Util::url_decode($el[1]);
} else { } else {
$value = ""; $value = "";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment