Merge pull request #101 from Nakilon/master

unescaped space symbol in redirect caused URI::InvalidURIError
This commit is contained in:
Stephen Sykes 2018-05-01 14:45:51 +03:00 committed by GitHub
commit a6222c47a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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

@ -249,8 +249,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