diff --git a/lib/fastimage.rb b/lib/fastimage.rb index a2ba55e..aab7443 100644 --- a/lib/fastimage.rb +++ b/lib/fastimage.rb @@ -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 diff --git a/test/test.rb b/test/test.rb index 1785129..82ef087 100644 --- a/test/test.rb +++ b/test/test.rb @@ -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