]> mj.ucw.cz Git - libucw.git/commitdiff
Merge branch 'dev-lib' of ssh://git.ucw.cz/projects/sherlock/GIT/sherlock into dev-lib
authorMichal Vaner <vorner@ucw.cz>
Sat, 13 Sep 2008 10:30:46 +0000 (12:30 +0200)
committerMichal Vaner <vorner@ucw.cz>
Sat, 13 Sep 2008 10:30:46 +0000 (12:30 +0200)
ucw/perl/CGI.pm

index 7d7cc4573b0158d2e22ad0266a590ac8367f80f8..acdb39cb786a98e21dc58c021a97682cf0333e15 100644 (file)
@@ -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/&/&amp;/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 ###