Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
relax request-line handling in Mojo::Message::Request (closes #571)
  • Loading branch information
kraih committed Mar 2, 2015
1 parent 024f666 commit 01709bc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,5 +1,6 @@

6.01 2015-03-02
- Relaxed request-line handling in Mojo::Message::Request.
- Fixed code name in version command and built-in templates.

6.0 2015-02-26
Expand Down
8 changes: 1 addition & 7 deletions lib/Mojo/Message/Request.pm
Expand Up @@ -10,12 +10,6 @@ has method => 'GET';
has url => sub { Mojo::URL->new };
has 'reverse_proxy';

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

sub clone {
my $self = shift;

Expand Down Expand Up @@ -61,7 +55,7 @@ sub extract_start_line {

# We have a (hopefully) full request-line
return !$self->error({message => 'Bad request start-line'})
unless $1 =~ $START_LINE_RE;
unless $1 =~ /^(\S+)\s+(\S+)\s+HTTP\/(\d\.\d)$/;
my $url = $self->method($1)->version($3)->url;
return !!($1 eq 'CONNECT' ? $url->authority($2) : $url->parse($2));
}
Expand Down
4 changes: 2 additions & 2 deletions t/mojo/request.t
Expand Up @@ -2070,12 +2070,12 @@ is $req->url->query->pairs->[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!\$%&'()*+,-./:;=?@[\\]^_`{|}~\xC3\x9F ");
$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%5C%5D%5E_%60%7B%7C%7D~',
is $req->url, "/#09azAZ!\$%&\'()*+,-./:;=?@%5B%5C%5D%5E_%60%7B%7C%7D~%C3%9F",
'right URL';

# Abstract methods
Expand Down

0 comments on commit 01709bc

Please sign in to comment.