You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered InvalidURIError error when dealing with the redirects to a location with // path. (e.g. https://google.com//).
After further investigation, I realized that HTTP doesn't allow to make a request to such urls at all.
The crux of the matter is HTTP::Request#headline method that uses Addressable::URI#omit method to get the path + query portion of the given url.
And while addressable allows to parse such urls http://google.com// and most of the methods work as expected, it fails with InvalidURIError when uri.omit(:authority) is called.
HTTP.get("https://google.com//")#Addressable::URI::InvalidURIError: Cannot have a path with two leading slashes without anauthority set: '//'
Reproducing with Addressable directly:
# Parse url with // pathurl=Addressable::URI.parse("https://google.com//")# Check that it works as expectedurl.path == "//"# Try to remove authorityurl.omit(:authority)# raises InvalidURIError
I was going to submit this issue to the addressable repository at first, but after the consideration I think that it's primarily the bug in HTTP.
Because Addressable is following the spec that disallows path with two leading slashes without the authority.
I've encountered InvalidURIError error when dealing with the redirects to a location with
//
path. (e.g.https://google.com//
).After further investigation, I realized that HTTP doesn't allow to make a request to such urls at all.
The crux of the matter is HTTP::Request#headline method that uses
Addressable::URI#omit
method to get the path + query portion of the given url.And while addressable allows to parse such urls
http://google.com//
and most of the methods work as expected, it fails withInvalidURIError
whenuri.omit(:authority)
is called.Relevant line in Addressable source code: https://github.com/sporkmonger/addressable/blob/8f4fee07243af0b788c625e59a9ca529489336d6/lib/addressable/uri.rb#L2427
Steps to reproduce
Reproducing with Addressable directly:
I was going to submit this issue to the addressable repository at first, but after the consideration I think that it's primarily the bug in HTTP.
Because Addressable is following the spec that disallows path with two leading slashes without the authority.
Ruby version:
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
Gem version:
http (2.1.0)
andaddressable (2.5.0)
The text was updated successfully, but these errors were encountered: