Skip to content

Commit

Permalink
improved Mojo::Message::Request to allow a few more ASCII characters …
Browse files Browse the repository at this point in the history
…in URLs
  • Loading branch information
kraih committed Jun 6, 2013
1 parent 6ba7319 commit 40ee1ed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,6 +1,7 @@

4.12 2013-06-06
- Improved Mojo::Message::Request to allow pipe symbol in URLs.
- Improved Mojo::Message::Request to allow a few more ASCII characters in
URLs.

4.11 2013-06-03
- Added allow and append methods to Mojo::Headers.
Expand Down
6 changes: 3 additions & 3 deletions lib/Mojo/Message/Request.pm
Expand Up @@ -11,10 +11,10 @@ has url => sub { Mojo::URL->new };

my $START_LINE_RE = qr/
^
([a-zA-Z]+) # Method
([a-zA-Z]+) # Method
\s+
([0-9a-zA-Z\-._~:\/?#[\]\{\}\@!\$&'()|*+,;=\%]+) # Path
(?:\s+HTTP\/(\d\.\d))? # Version
([0-9a-zA-Z!#\$\%&'()*+,\-.\/:;=?\@[\\\]^_`\{|\}~]+) # Path
(?:\s+HTTP\/(\d\.\d))? # Version
$
/x;

Expand Down
5 changes: 3 additions & 2 deletions t/mojo/request.t
Expand Up @@ -1893,11 +1893,12 @@ is $req->url->query->params->[0], 'Mojo::Message::Request', 'right value';

# Parse lots of special characters in URL
$req = Mojo::Message::Request->new;
$req->parse('GET /#09azAZ-._~:/?[]{}@!$&\'()|*+,;=% ');
$req->parse('GET /#09azAZ!$%&\'()*+,-./:;=?@[\\]^_`{|}~ ');
$req->parse("HTTP/1.1\x0d\x0a\x0d\x0a");
ok $req->is_finished, 'request is finished';
is $req->method, 'GET', 'right method';
is $req->version, '1.1', 'right version';
is $req->url, '/#09azAZ-._~:/?%5B%5D%7B%7D@!$&\'()%7C*+,;=%', 'right URL';
is $req->url, '/#09azAZ!$%&\'()*+,-./:;=?@%5B%5C%5D%5E_%60%7B%7C%7D~',
'right URL';

done_testing();

0 comments on commit 40ee1ed

Please sign in to comment.