Bug#516129: perl-modules: CGI.pm unwanted UTF-8 conversion in URLs

Kiss Gabor (Bitman) kissg at ssg.ki.iif.hu
Thu Feb 19 14:46:19 UTC 2009


Hi Niko,

> > 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 part of the code was changed in CGI.pm 3.30, while perl-modules has 3.29.
> 
> http://search.cpan.org/diff?from=CGI.pm-3.29&to=CGI.pm-3.31#CGI/Util.pm
> 
> Could you please check if installing the separate libcgi-pm-perl package
> (lenny is at 3.38, squeeze/sid at 3.42) fixes this for you?

Unfortunately 3.38 does not work.
New statement in CGI::Util::escape() is this:

$toencode = eval { pack("U*", unpack("U0C*", $toencode))} ||
			pack("C*", unpack("C*", $toencode));

It checks carefully if UTF-8 chars are usable.
Accidentally the first (eval'ed) unpack/pack() is "successful"
i.e. it does not crash, so the UTF-8 encoding remains in effect. :-(
Meanwhile I need pack("C*", unpack("C*", $toencode)).
(That is actually equivalent to $toencode isn't it? :-)

CGI.pm in general does not care how the original page was encoded
and what coding the browser uses when sends back CGI params.

Regards

Gabor






More information about the Perl-maintainers mailing list