From: b Date: Fri, 29 Dec 2023 01:55:52 +0000 (+0000) Subject: URL decode + X-Git-Tag: v1.0.24 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=refs%2Ftags%2Fv1.0.24;p=botm%2Fcommon-perl URL decode + --- diff --git a/botm_common.pm b/botm_common.pm index 528b2ff..e3f4c83 100644 --- a/botm_common.pm +++ b/botm_common.pm @@ -25,7 +25,7 @@ use Encode ('encode', 'decode'); use Exporter; -our $VERSION = '1.0.23'; +our $VERSION = '1.0.24'; our @ISA = qw(Exporter); our @EXPORT = (); our @EXPORT_OK = ( @@ -589,12 +589,16 @@ sub url_encode_1ch { # $t is the text to decode. # $encoding is the encoding to use # (if left empty, utf8 is assumed) +# if $plus is true then '+' will be decoded to ' '. sub url_decode { - (my $t, my $encoding) = @_; + (my $t, my $encoding, my $plus) = @_; if ($encoding eq '') { $encoding = 'utf8'; } + if ($plus) { + $t =~ s/\+/ /gs; + } $t =~ s/((%[0-9A-Fa-f]{2})+)/url_decode_xch($1, $encoding)/egs; return $t; } @@ -797,8 +801,8 @@ sub url_query_decode { my @list = split('&', $query); foreach my $entry (@list) { (my $name, my $value) = split('=', $entry, 2); - $name = url_decode($name, $encoding); - $value = url_decode($value, $encoding); + $name = url_decode($name, $encoding, 1); + $value = url_decode($value, $encoding, 1); $data{$name} = $value; } return %data;