From 93b2a50923c63abf29fe418b976be042719d6c87 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 13 Sep 2008 12:28:53 +0200 Subject: [PATCH] CGI.pm: Export URL and parameter de-escaping functions. --- ucw/perl/CGI.pm | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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 ### -- 2.39.2