From: Martin Mares Date: Sat, 13 Sep 2008 10:28:53 +0000 (+0200) Subject: CGI.pm: Export URL and parameter de-escaping functions. X-Git-Tag: holmes-import~305^2 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=93b2a50923c63abf29fe418b976be042719d6c87;p=libucw.git CGI.pm: Export URL and parameter de-escaping functions. --- diff --git a/ucw/perl/CGI.pm b/ucw/perl/CGI.pm index 7d7cc457..acdb39cb 100644 --- a/ucw/perl/CGI.pm +++ b/ucw/perl/CGI.pm @@ -57,7 +57,7 @@ use warnings; require Exporter; our $VERSION = 1.0; our @ISA = qw(Exporter); -our @EXPORT = qw(&html_escape &url_escape &url_param_escape &self_ref &self_form &http_get); +our @EXPORT = qw(&html_escape &url_escape &url_deescape &url_param_escape &url_param_deescape &self_ref &self_form &http_get); our @EXPORT_OK = qw(); ### Escaping ### @@ -68,6 +68,12 @@ sub url_escape($) { return $x; } +sub url_deescape($) { + my $x = shift @_; + $x =~ s/%(..)/pack("H2",$1)/ge; + return $x; +} + sub url_param_escape($) { my $x = shift @_; $x = url_escape($x); @@ -75,6 +81,12 @@ sub url_param_escape($) { return $x; } +sub url_param_deescape($) { + my $x = shift @_; + $x =~ s/\+/ /g; + return url_deescape($x); +} + sub html_escape($) { my $x = shift @_; $x =~ s/&/&/g; @@ -105,8 +117,7 @@ sub rfc822_prepare($) { sub rfc822_deescape($) { my $x = shift @_; - $x =~ s/%(..)/pack("H2",$1)/ge; - return $x; + return url_deescape($x); } ### Reading of HTTP headers ###