tag 516129 patch fixed-upstream
forwarded 516129 http://rt.perl.org/rt3/Public/Bug/Display.html?id=49055
thanks
On Thu, Feb 19, 2009 at 01:54:48PM +0100, Gabor Kiss wrote:
> Package: perl-modules
> Version: 5.10.0-19
> Severity: normal
>
> Function url(-path-info=>1) does not work well if I have ISO-8859-2
> accented chars in the URL. Utility function CGI::Util::escape()
> unconditionally forces an ISO-8859-1 -> UTF-8 conversion:
>
> # force bytes while preserving backward compatibility -- dankogai
> $toencode = pack("C*", unpack("U0C*", $toencode));
>
> This code produces from original URL "...&word_to_search=v%E1ros&..."
> another one: "...&word_to_search==v%C3%A1ros&..."
Hi Gabor,
I believe this is fixed in CGI.pm-3.43 with the attached patch.
Could you please grab libcgi-pm-perl 3.43-1 from unstable and verify
it works for you?
This is also [perl #49055].
Cheers,
--
Niko Tyni [email protected]
--- ../perl/lib/CGI/Util.pm 2009-04-14 23:46:17.000000000 +0300
+++ lib/CGI/Util.pm 2009-04-22 21:32:05.000000000 +0300
@@ -196,12 +196,24 @@
}
# URL-encode data
+#
+# We cannot use the %u escapes, they were rejected by W3C, so the official
+# way is %XX-escaped utf-8 encoding.
+# Naturally, Unicode strings have to be converted to their utf-8 byte
+# representation. (No action is required on 5.6.)
+# Byte strings were traditionally used directly as a sequence of octets.
+# This worked if they actually represented binary data (i.e. in CGI::Compress).
+# This also worked if these byte strings were actually utf-8 encoded; e.g.,
+# when the source file used utf-8 without the apropriate "use utf8;".
+# This fails if the byte string is actually a Latin 1 encoded string, but it
+# was always so and cannot be fixed without breaking the binary data case.
+# -- Stepan Kasal <[email protected]>
+#
sub escape {
shift() if @_ > 1 and ( ref($_[0]) || (defined $_[1] && $_[0] eq $CGI::DefaultClass));
my $toencode = shift;
return undef unless defined($toencode);
- # force bytes while preserving backward compatibility -- dankogai
- $toencode = pack("C*", unpack("U0C*", $toencode));
+ utf8::encode($toencode) if ($] > 5.007 && utf8::is_utf8($toencode));
if ($EBCDIC) {
$toencode=~s/([^a-zA-Z0-9_.~-])/uc sprintf("%%%02x",$E2A[ord($1)])/eg;
} else {