[Catalyst] Re: Patch for Catalyst::Plugin::Unicode::Encoding

Tatsuhiko Miyagawa miyagawa at gmail.com
Sat Mar 22 06:57:12 GMT 2008


On 3/21/08, Jonathan Rockway <jon at jrock.us> wrote:
> The need to check if something is already decoded hints at the existence
> of other bugs.

Yes. As we talked the other day on irc, the fact there's no consensus
which plugin to decode $c->req->param and anyone can write a plugin to
do that, to make a messy situation like this, is considered a bug.

> Encoding/decoding really boils down to knowing *for
> sure* what data you already have.  If we don't know what data we have,
> we can't safely decode it.

Yes, and perl 5.x doesn't have a programatic way to know this. Sad.

> Is anyone having a problem with decoding things that are already
> decoded?  Or is this only a theoretical problem?

Encode.pm dies if you try to decode an already decoded string.

> perl -MEncode -we '$s=chr(0x1234); Encode::decode("utf-8",$s)'
Cannot decode string with wide characters at
/System/Library/Perl/5.8.6/darwin-thread-multi-2level/Encode.pm line
162.

Interestingly, utf8::decode() and Encode::encode_utf8() are safe to
this. They don't die and just ignore your stupidness, which may be
good.

-
Tatsuhiko Miyagawa



More information about the Catalyst mailing list