FAQ
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?

http://dev.catalyst.perl.org/svnweb/Catalyst/view/Catalyst-Runtime/5.70/trunk/lib/Catalyst/DispatchType/Path.pm?revh97

BTW --

3178 matthewt $path = URI->new($path)->canonical;

If I try to get to that version in svn I get a redirect loop:

http://dev.catalyst.perl.org/svnweb/Catalyst/log/Catalyst-Runtime/5.70/trunk/lib/Catalyst/DispatchType/Path.pm
(click on the link "/trunk/Catalyst-Runtime:6895")



--
Bill Moseley
moseley@hank.org

Search Discussions

  • Bill Moseley at Mar 24, 2008 at 4:22 pm

    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
    moseley@hank.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedMar 24, '08 at 1:24p
activeMar 24, '08 at 4:22p
posts2
users1
websitecatalystframework.org
irc#catalyst

1 user in discussion

Bill Moseley: 2 posts

People

Translate

site design / logo © 2022 Grokbase