unescaped space symbol in redirect caused URI::InvalidURIError

This commit is contained in:
Victor Maslov 2018-04-25 22:48:36 +03:00
parent c7cad12fa0
commit abccdd1365
2 changed files with 3 additions and 3 deletions

View File

@ -250,7 +250,7 @@ class FastImage
if res.is_a?(Net::HTTPRedirection) && @redirect_count < 4
@redirect_count += 1
begin
@parsed_uri = URI.join(@parsed_uri, res['Location'])
@parsed_uri = URI.join(@parsed_uri, URI.escape(res['Location']))
rescue URI::InvalidURIError
else
fetch_using_http_from_parsed_uri

View File

@ -248,8 +248,8 @@ class FastImageTest < Test::Unit::TestCase
end
def test_should_handle_permanent_redirect_with_complex_relative_url
register_redirect(TestUrl, "/photo.gne?rb=1&short=Vv4Und")
register_redirect("#{TestUrl}photo.gne?rb=1&short=Vv4Und", "/" + GoodFixtures.keys.first)
register_redirect(TestUrl, "/pho to.gne?rb=1&short=Vv4Und")
register_redirect("#{TestUrl}pho%20to.gne?rb=1&short=Vv4Und", "/" + GoodFixtures.keys.first)
assert_equal GoodFixtures[GoodFixtures.keys.first][1], FastImage.size(TestUrl, :raise_on_failure=>true)
end