Permalink
Browse files

Merge pull request #292 from ssmccoy/rfc-1738

Path escaping regex supports RFC 3986 definition.
  • Loading branch information...
2 parents 9b7b2fe + 5f9c372 commit be119992bdb00ea5b1db0bdba6530bba7244b03f @miyagawa miyagawa committed Aug 13, 2012
Showing with 19 additions and 3 deletions.
  1. +3 −2 lib/Plack/Request.pm
  2. +16 −1 t/Plack-Request/uri.t
View
@@ -185,8 +185,9 @@ sub uri {
# This means when a request like /foo%2fbar comes in, we recognize
# it as /foo/bar which is not ideal, but that's how the PSGI PATH_INFO
# spec goes and we can't do anything about it. See PSGI::FAQ for details.
- # http://github.com/plack/Plack/issues#issue/118
- my $path_escape_class = '^A-Za-z0-9\-\._~/';
+
+ # See RFC 3986 before modifying.
+ my $path_escape_class = q{^/;:@&=A-Za-z0-9$_.+!*'(),-};
my $path = URI::Escape::uri_escape($self->env->{PATH_INFO} || '', $path_escape_class);
$path .= '?' . $self->env->{QUERY_STRING}
View
@@ -43,6 +43,13 @@ my @tests = (
},
uri => 'http://example.com/exec/',
parameters => {} },
+
+ { add_env => {
+ HTTP_HOST => 'example.com',
+ SCRIPT_NAME => '/exec/'
+ },
+ uri => 'http://example.com/exec/',
+ parameters => {} },
{ add_env => {
SERVER_NAME => 'example.com'
},
@@ -85,7 +92,15 @@ my @tests = (
PATH_INFO => "/baz quux",
},
uri => 'http://example.com/foo%20bar/baz%20quux',
- parameters => {} }
+ parameters => {} },
+ { add_env => {
+ HTTP_HOST => 'example.com',
+ SCRIPT_NAME => "/path",
+ PATH_INFO => "/parameters;path=one,two",
+ QUERY_STRING => "query=foobar",
+ },
+ uri => 'http://example.com/path/parameters;path=one,two?query=foobar',
+ parameters => { query => "foobar" } },
);
plan tests => 2 * @tests;

0 comments on commit be11999

Please sign in to comment.