Encode square brackets in path segments#9410
Conversation
|
@swankjesse on your 2023 ask about confirming browsers. Browsers per WHATWG leave Should I close this? |
|
The "encoded" variants of the functions are the "raw" ones. These functions are the ones which are used by 99.9% of callers. We should fix these. Retrofit wants this! |
|
Kept it open. |
swankjesse
left a comment
There was a problem hiding this comment.
I would prefer we not change the existing behavior here. Even if a different behavior is more correct per some specs, it’ll result in different HTTP calls being made to servers, which means different data being served to callers.
https://publicobject.com/2017/08/01/url-encoding-is-material/
Now . . . introducing a new function here? Hmmm... I’m unsure how I feel about this.
|
Not sure if this is a compelling argument, but if I type |
|
Yeah, same result here, |
HttpUrl.Builder.addPathSegment()andsetPathSegment()did not percent-encode[and]in path segments. RFC 3986 section 3.3 reserves brackets for IPv6 literals in the authority component, so they should be percent-encoded when they appear in path segments.Added a
PATH_SEGMENT_ENCODE_SET_RAWconstant that includes[]and applied it to raw-input methods (addPathSegment,addPathSegments,setPathSegment).addEncodedPathSegment(),setEncodedPathSegment(), and URL parsing preserve literal brackets as before.Fixes #6790