Skip to content

Some bad sites gives in location header URL without proper encoding #189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/open-uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ def OpenURI.open_http(buf, target, proxy, options) # :nodoc:
Net::HTTPSeeOther, # 303
Net::HTTPTemporaryRedirect # 307
begin
loc_uri = URI.parse(resp['location'])
# Some bad formed sites responds location with unescaped special chars.
# Just a new URI.encode solve this.
loc_uri = URI.parse(URI.encode(resp['location']))
rescue URI::InvalidURIError
raise OpenURI::HTTPError.new(io.status.join(' ') + ' (Invalid Location URI)', io)
end
Expand Down