Package: libhtml-mason-perl Version: 1:1.35-2 Severity: normal Tags: patch Hi,
investigating #387104 and #416097, I have discovered an incompatibility in the output encoding between HTML::Mason::CGIHandler and HTML::Mason::ApacheHandler. As far as I understand, CGIHandler is supposed to emulate ApacheHandler, so I consider this a bug. The problem is that mod_perl (including mod_perl2) doesn't care about the Perl internal UTF8 flag on output of non-ASCII strings, but output coming through HTML::Mason::CGIHandler does. In the CGI case, the output is converted to ISO-8859-1 automatically, while mod_perl just outputs the internal encoding of the strings, which happens to be UTF-8. It can be argued that the mod_perl behaviour is wrong here, but at least Request Tracker depends on it and thus fails badly when used in a CGI environment (usually through SpeedyCGI). I'm attaching the configuration for a minimal testcase that can be enabled with something like this # cp masontest.conf /etc/apache/conf.d # cp handler.cgi cgi.mason /var/www # ln -s cgi.mason /var/www/mod_perl.mason # /etc/init.d/apache restart We now see that the CGI output is in ISO-8859-1 while the mod_perl output is in UTF-8: % curl -s http://localhost/cgi.mason | od -c 0000000 344 \n 0000002 % curl -s http://localhost/mod_perl.mason | od -c 0000000 303 244 \n 0000003 The fix is simple: just add "use bytes" into the default output method of HTML::Mason::CGIHandler. I'm attaching a patch that does this. The HTML::Mason::CGIHandler documentation indicates that there's no need for backwards compatibility in this case, but I would be happy with a way to turn this on optionally if that's preferred. Please fix this, it's making RT unusable with SpeedyCGI. Cheers, -- Niko Tyni [EMAIL PROTECTED]
ScriptAlias /handler.cgi /var/www/handler.cgi <Location /cgi.mason> Action html-mason /handler.cgi SetHandler html-mason </Location> PerlModule HTML::Mason::ApacheHandler <Location /mod_perl.mason> SetHandler perl-script PerlHandler HTML::Mason::ApacheHandler </Location>
<%init> use charnames ':full'; my $str = "\N{LATIN SMALL LETTER A WITH DIAERESIS}"; </%init> <% $str %>
#!/usr/bin/perl -w use strict; use HTML::Mason::CGIHandler; my $h = HTML::Mason::CGIHandler->new; $h->handle_request;
--- /usr/share/perl5/HTML/Mason/CGIHandler.pm 2007/03/29 07:43:25 1.1 +++ /usr/share/perl5/HTML/Mason/CGIHandler.pm 2007/03/29 07:43:46 @@ -99,6 +99,9 @@ $sent_headers = 1; } + # mimic mod_perl behaviour + use bytes; + # We could perhaps install a new, faster out_method here that # wouldn't have to keep checking whether headers have been # sent and what the $r->method is. That would require