From: Gregor Schmidt Date: 2010-06-20T19:01:48+09:00 Subject: [ruby-core:30834] [Bug #3457] URI.encode does not escape square brackets Bug #3457: URI.encode does not escape square brackets http://redmine.ruby-lang.org/issues/show/3457 Author: Gregor Schmidt Status: Open, Priority: Normal Category: lib ruby -v: ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10.0.0] 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. ---------------------------------------- http://redmine.ruby-lang.org