Skip Menu |

This queue is for tickets about the CGI-Simple CPAN distribution.

Report information
The Basics
Id: 12481
Status: resolved
Priority: 0/
Queue: CGI-Simple

People
Owner: Nobody in particular
Requestors: jpritikin@pobox.com (no email address)
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: UTF8 data from forms is mangled
What magic is needed to receive UTF8 data from forms? It seems like Encode::decode_utf8 is needed somewhere but I'm not sure where.
From: BEROV [...] cpan.org
Hi, here is a patch for CGI-Simple-1.103 which solves the problem :). It follows the principle of keeping compatibility with CGI.pm. On Sat Apr 30 11:17:11 2005, guest wrote: Show quoted text
> What magic is needed to receive UTF8 data from forms? It seems like > Encode::decode_utf8 is needed somewhere but I'm not sure where.
Index: Simple.pm =================================================================== --- Simple.pm (revision 66) +++ Simple.pm (working copy) @@ -10,7 +10,7 @@ use vars qw( $VERSION $USE_CGI_PM_DEFAULTS $DISABLE_UPLOADS $POST_MAX - $NO_UNDEF_PARAMS $USE_PARAM_SEMICOLONS $HEADERS_ONCE + $NO_UNDEF_PARAMS $USE_PARAM_SEMICOLONS $PARAM_UTF8 $HEADERS_ONCE $NPH $DEBUG $NO_NULL $FATAL *in ); @@ -46,6 +46,10 @@ # separate the name=value pairs with ; rather than & $USE_PARAM_SEMICOLONS = 0 unless defined $USE_PARAM_SEMICOLONS; + + # return everything as utf-8 + $PARAM_UTF8 ||= 0; + $PARAM_UTF8 and require Encode; # only print headers once $HEADERS_ONCE = 0 @@ -82,6 +86,7 @@ $DEBUG = 1 unless defined $DEBUG; $NO_NULL = 0 unless defined $NO_NULL; $FATAL = -1 unless defined $FATAL; + $PARAM_UTF8 = 0 unless defined $PARAM_UTF8; } # this is called by new, we will never directly reference the globals again @@ -98,6 +103,7 @@ $self->{'.globals'}->{'NO_NULL'} = $NO_NULL; $self->{'.globals'}->{'FATAL'} = $FATAL; $self->{'.globals'}->{'USE_CGI_PM_DEFAULTS'} = $USE_CGI_PM_DEFAULTS; + $self->{'.globals'}->{'PARAM_UTF8'} = $PARAM_UTF8; } # use the automatic calling of the import sub to set our pragmas. CGI.pm compat @@ -420,6 +426,8 @@ if $value eq '' and $self->{'.globals'}->{'NO_UNDEF_PARAMS'}; $value =~ tr/\000//d if $self->{'.globals'}->{'NO_NULL'}; + $value = Encode::decode(utf8=> $value) + if $self->{'.globals'}->{PARAM_UTF8}; push @{ $self->{$param} }, $value; unless ( $self->{'.fieldnames'}->{$param} ) { push @{ $self->{'.parameters'} }, $param;
Thanks. This should be fixed in 1.106.