Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix small redirect bug in Mojo::UserAgent::Transactor
  • Loading branch information
kraih committed Oct 1, 2015
1 parent 9647b65 commit 78792b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,5 +1,6 @@

6.23 2015-09-30
6.23 2015-10-01
- Fixed small redirect bug in Mojo::UserAgent::Transactor.

6.22 2015-09-26
- Improved Mojo::JSON by reusing JSON::PP boolean constants.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/UserAgent/Transactor.pm
Expand Up @@ -75,7 +75,7 @@ sub redirect {
$location = Mojo::URL->new($location);
$location = $location->base($old->req->url)->to_abs unless $location->is_abs;
my $proto = $location->protocol;
return undef unless $proto eq 'http' || $proto eq 'https';
return undef if ($proto ne 'http' && $proto ne 'https') || !$location->host;

# Clone request if necessary
my $new = Mojo::Transaction::HTTP->new;
Expand Down
4 changes: 4 additions & 0 deletions t/mojo/transactor.t
Expand Up @@ -825,6 +825,10 @@ $tx = $t->tx(GET => 'http://mojolicio.us/foo');
$tx->res->code(302);
$tx->res->headers->location('data:image/png;base64,helloworld123');
is $t->redirect($tx), undef, 'unsupported redirect';
$tx = $t->tx(GET => 'http://mojolicio.us/foo');
$tx->res->code(302);
$tx->res->headers->location('http:');
is $t->redirect($tx), undef, 'unsupported redirect';

# 302 redirect (relative path and query)
$tx = $t->tx(
Expand Down

0 comments on commit 78792b2

Please sign in to comment.