From 77c84c65dc22afe21bc52d95cd3996b8e1c7d065 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 18 Apr 2014 12:44:53 +0200 Subject: [PATCH] UCW::CGI: Let url_param_escape() encode non-ASCII characters RFC 3986 (generic URI syntax) explicitly says this must be done and some URI parsers choke on them. Anyway, I am keeping bare url_escape() as is for the time being, because it's used for production of user-friendly URLs, too. Needs cleanup later. --- ucw/perl/UCW/CGI.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ucw/perl/UCW/CGI.pm b/ucw/perl/UCW/CGI.pm index f81bd3ea..a18ee8ea 100644 --- a/ucw/perl/UCW/CGI.pm +++ b/ucw/perl/UCW/CGI.pm @@ -50,8 +50,10 @@ sub url_deescape($) { sub url_param_escape($) { my $x = shift @_; defined $x or return; - $x = url_escape($x); + utf8::encode($x) if $utf8_mode; + $x =~ s/([^-\$_.!*'(),0-9A-Za-z])/"%".unpack('H2',$1)/ge; $x =~ s/%20/+/g; + utf8::decode($x) if $utf8_mode; return $x; } -- 2.39.2