peter pilsl wrote:
I need to process and output data delivered via a webbrowser using the CGI-interface.
To deal with "real" unicode-data I set the whole STDIN and STDOUT to utf8 with binmode (as recommended at http://www.perldoc.com/perl5.8.0/pod/perluniintro.html. My script would not work otherwise)


While this works perfect in a standard CGI-environment it does not work under mod_perl. Perl reads the input from the CGI-form and does not read it as unicode.

STDIN is not used with mod_perl. I'd say, don't use CGI::param() directly, use your own param wrapper function(s) that call Encode::decode_utf8() or utf8::decode() for the returned values. Wrapper functions are useful anyway for untainting input or supporting more than one CGI input module (like Apache::Request in addition to CGI.pm).


Simplified example:

sub param
{
  my $str = undef;
  if (MODPERL) { $str = $apr->param(shift()) }
  else { $str = $cgi->param(shift()) }
  utf8::decode($str);
  return $str;
}

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Reply via email to