On Mon, Mar 24, 2008 at 06:24:12AM -0700, Bill Moseley wrote:
> I noticed that register_path uses URI->canonical:
> 
> sub register_path {
>     my ( $self, $c, $path, $action ) = @_;
>     $path =~ s!^/!!;
>     $path = '/' unless length $path;
>     $path = URI->new($path)->canonical;
> 
>     unshift( @{ $self->{paths}{$path} ||= [] }, $action);
> 
>     return 1;
> }
> 
> I'm confused, when would a Path attribute be a full URI?


Oh, $path can be encoded.  That is, for a request:

    http://localhost:3000/hello%20there

then $path will be 'hello%20there'

And if there's an action:

    sub howdy : Path( 'hello there' ) {

Then:

    $ perl -MURI -le 'print URI->new("hello there")->canonical'
    hello%20there

So the dispatcher is storing 'hello%20there' and it will match the
$path.


But, why use encoded data on the inside of the application?

Here's an example of how it could fail:

If I replace an "e" with %65

    http://localhost:3000/hello%20th%65re

Which should be the same URL.

And then the dispatcher is trying to match this $path:

    hello%20th%65re

But, as above, the dispatcher is storing:

    hello%20there

so it won't match.



-- 
Bill Moseley
[EMAIL PROTECTED]


_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to