How would this patch affect systems that choose to encode their URLs in something other than UTF-8? (Other character encodings are widely used, particularly on Asian sites).
There might be a case for having the encoding type as a configurable option (where one option is no decoding so the application can handle it) - otherwise it has to be left to the application where the app designers can reverse whatever encoding they have chosen. -- Jon Schutz My tech notes http://notes.jschutz.net Chief Technology Officer http://www.youramigo.com YourAmigo On 09/09/2009 11:15 AM, Rod Taylor wrote: > I have a URL which includes UTF8 components which are in the chained > (CaptureArgs) position. The escape mechanism is supposed encode each > byte of the UTF8 sequence individually when creating the URL (which > Catalyst seems to do) and reverse this on the way in. > > The below adjustment appears to fix the issue I'm having with URL > arguments not being decoded on the way in. > > This may not be the right place to handle it as it could break older > applications which work around arguments not being decoded properly to UTF8. > > This makes a good test URL. > > $uri = $c->uri_for( $cont->action_for($action), ['VÜ Living', '他们有理 > 性和良心' ]); > > Should result in VÜ Living and 他们有理性和良心 being in the first and > second captured arguments. > > > *** Chained.pm.orig Tue Sep 8 21:10:10 2009 > --- Chained.pm Tue Sep 8 21:35:38 2009 > *************** > *** 168,174 **** > > $request->action("/${action}"); > $request->match("/${action}"); > ! $request->captures($captures); > $c->action($action); > $c->namespace( $action->namespace ); > > --- 168,187 ---- > > $request->action("/${action}"); > $request->match("/${action}"); > ! > ! # Decode Captures > ! my $decodedCaptures = []; > ! if ($captures && @$captures) { > ! for my $arg (@{$captures}) { > ! $arg =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg; > ! utf8::downgrade($arg); > ! utf8::decode($arg); > ! push(@{$decodedCaptures}, $arg); > ! } > ! } > ! $request->captures($decodedCaptures); > $c->action($action); > $c->namespace( $action->namespace ); > > > ------------------------------------------------------------------------ > > _______________________________________________ > List: Catalyst@lists.scsys.co.uk > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ > Dev site: http://dev.catalyst.perl.org/ _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/