This project is closed and read-only.
Bug #3457
closedURI.encode does not escape square brackets
Description
=begin
According to RFC 3986 URIs may only contain square brackets to enclose IPv6 addresses within the host part of the URI. In other parts of the uri the are not allowed and need to be escaped.
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.
Square brackets are now specified as reserved within the
authority component and are not allowed outside their use as
delimiters for an IP literal within host.
The attached test case should test the desired behavior. I've tested it on 1.8.7 but I a would guess, that it is failing for all major ruby versions and interpreters.
I'm not sure, how this should be implemented while keeping the API of URI.escape in tact. The escaping needs to use two groups of safe characters, one for the host part and one for the rest. This would result in 2 optional parameters for URI.escape to provide custom safe characters for each part.
=end
Files