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
A host identified by an Internet Protocol literal address, version 6
[RFC3513] or later, is distinguished by enclosing the IP literal
within square brackets ("[" and "]"). This is the only place where
square bracket characters are allowed in the URI syntax.
Given this, I think they should be included at the lowest level encode set, QUERY_ENCODE_SET. I think SIMPLE_ENCODE_SET could also be used in places where the ip address specification above would be valid, so I wouldn't recommend it there (though I could also be interpreting this incorrectly).
This would also more closely follow the behavior of Javascript's encodeURI. Mozilla's documentation also mentions handling of RFC3986:
Also note that if one wishes to follow the more recent RFC3986 for URLs, which makes square brackets reserved (for IPv6) and thus not encoded when forming something which could be part of a URL (such as a host), the following code snippet may help:
function fixedEncodeURI(str) {
return encodeURI(str).replace(/%5B/g, '[').replace(/%5D/g, ']');
}
So by not encoding square brackets in SIMPLE_ENCODE_SET, hosts could be encoded while leaving the brackets unchanged, while for other parts of the URL, it would be encoded.
The text was updated successfully, but these errors were encountered:
Per page 18 of RFC 3986:
Given this, I think they should be included at the lowest level encode set, QUERY_ENCODE_SET. I think SIMPLE_ENCODE_SET could also be used in places where the ip address specification above would be valid, so I wouldn't recommend it there (though I could also be interpreting this incorrectly).
This would also more closely follow the behavior of Javascript's encodeURI. Mozilla's documentation also mentions handling of RFC3986:
So by not encoding square brackets in SIMPLE_ENCODE_SET, hosts could be encoded while leaving the brackets unchanged, while for other parts of the URL, it would be encoded.
The text was updated successfully, but these errors were encountered: