From: Martin Mares Date: Tue, 15 Oct 2013 12:41:10 +0000 (+0200) Subject: UCW::CGI: Escaping functions silently convert undef to undef X-Git-Tag: v5.99~77 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;ds=sidebyside;h=5453cb799a65190b348028302249af928c58cee4;p=libucw.git UCW::CGI: Escaping functions silently convert undef to undef --- diff --git a/ucw/perl/UCW/CGI.pm b/ucw/perl/UCW/CGI.pm index 7cb34639..f81bd3ea 100644 --- a/ucw/perl/UCW/CGI.pm +++ b/ucw/perl/UCW/CGI.pm @@ -31,6 +31,7 @@ sub http_error($;@) { sub url_escape($) { my $x = shift @_; + defined $x or return; utf8::encode($x) if $utf8_mode; $x =~ s/([^-\$_.!*'(),0-9A-Za-z\x80-\xff])/"%".unpack('H2',$1)/ge; utf8::decode($x) if $utf8_mode; @@ -39,6 +40,7 @@ sub url_escape($) { sub url_deescape($) { my $x = shift @_; + defined $x or return; utf8::encode($x) if $utf8_mode; $x =~ s/%(..)/pack("H2",$1)/ge; utf8::decode($x) if $utf8_mode; @@ -47,6 +49,7 @@ sub url_deescape($) { sub url_param_escape($) { my $x = shift @_; + defined $x or return; $x = url_escape($x); $x =~ s/%20/+/g; return $x; @@ -54,12 +57,14 @@ sub url_param_escape($) { sub url_param_deescape($) { my $x = shift @_; + defined $x or return; $x =~ s/\+/ /g; return url_deescape($x); } sub html_escape($) { my $x = shift @_; + defined $x or return; $x =~ s/&/&/g; $x =~ s//>/g;