Skip Menu |

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

Report information
The Basics
Id: 69193
Status: new
Priority: 0/
Queue: Web-Simple

People
Owner: Nobody in particular
Requestors: EWILHELM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.008
Fixed in: (no value)



Subject: over-zealous "extension" stripping
With no 'extension' on the end of an unslashed path, anything after a dot is stripped, so that e.g. "sub (/user/*) {...}" would be unable to have dots in the user id. The following was added in commit e7dd1c4b36aca6dffb4272f078966906d4b2f407. length and $_ .= '(?:\.\w+)?' for $path[-1]; Confusingly, t/dispatch_parser.t says "one.html" parses as "one" even though it has no '.html' in the spec. I think this is incorrect and that Predicates.pm's match_extension() should strip the extension if specified rather than having Parser.pm mess with it. (Note that without the match_extension() s/// change, the t/response-filter.t will fail.)
Subject: extensions.patch
commit 9a1acbbaaa4899cc6f7e0ad26b72e25af6dd3f52 Author: Eric Wilhelm <ewilhelm@cpan.org> Date: Wed Jun 29 16:49:50 2011 -0700 * allow unslashed paths to have dots in them even without an extension lib/Web/Dispatch/Parser.pm - was stripping any arbitrary extension lib/Web/Dispatch/Predicates.pm - strip the extension when we see it here t/dispatch_parser.t - correct expectations around '.html' handling diff --git a/lib/Web/Dispatch/Parser.pm b/lib/Web/Dispatch/Parser.pm index ad05e5d..aaac61d 100644 --- a/lib/Web/Dispatch/Parser.pm +++ b/lib/Web/Dispatch/Parser.pm @@ -133,9 +133,6 @@ sub _url_path_match { push @path, $self->_url_path_segment_match($_) or $self->_blam("Couldn't parse path match segment"); } - if (@path && !$end) { - length and $_ .= '(?:\.\w+)?' for $path[-1]; - } my $re = '^('.join('/','',@path).')'.$end.'$'; $re = qr/$re/; if ($end) { diff --git a/lib/Web/Dispatch/Predicates.pm b/lib/Web/Dispatch/Predicates.pm index 758afed..5883a34 100644 --- a/lib/Web/Dispatch/Predicates.pm +++ b/lib/Web/Dispatch/Predicates.pm @@ -93,7 +93,7 @@ sub match_extension { ? qr/\.(\w+)$/ : qr/\.(\Q${extension}\E)$/; sub { - if ($_[0]->{PATH_INFO} =~ $re) { + if ($_[0]->{PATH_INFO} =~ s/$re//) { ($wild ? ({}, $1) : {}); } else { (); diff --git a/t/dispatch_parser.t b/t/dispatch_parser.t index caa4e45..bb4dc51 100644 --- a/t/dispatch_parser.t +++ b/t/dispatch_parser.t @@ -72,12 +72,12 @@ my $dp = Web::Dispatch::Parser->new; } { - my $post = $dp->parse('/post/*'); + my $post = $dp->parse('.html + /post/*'); is_deeply( - [ $post->({ PATH_INFO => '/post/one' }) ], - [ {}, 'one' ], - '/post/one parses out one' + [ $post->({ PATH_INFO => '/post/one.foo' }) ], + [], + '/post/one.foo does not match' ); is_deeply( @@ -89,7 +89,7 @@ my $dp = Web::Dispatch::Parser->new; is_deeply( [ $post->({ PATH_INFO => '/post/one.html' }) ], [ {}, 'one' ], - '/post/one.html still parses out one' + '/post/one.html parses out one' ); }