Project

General

Profile

Actions

Bug #9990

closed

URI.parse and URI.encode use different RFCs

Added by lengarvey (Leonard Garvey) over 10 years ago. Updated almost 7 years ago.

Status:
Closed
Target version:
-
ruby -v:
2.2.0dev
[ruby-core:63390]

Description

The latest code for URI.parse uses RFC3986 but URI.encode/URI.escape still uses the old URI::RFC2396_Parser implementation of encode. This causes problems when the specs diverge.

In RFC3986 square brackets "[" and "]" are reserved and need to be percent encoded in the query string, although they didn't in RFC2396. This means the the following url cannot be parsed by the new parser, and isn't encoded correctly by the old encoder: https://bugs.ruby-lang.org/projects/ruby-trunk/issues?set_filter=1&f[]=status_id&op[status_id]=o

Here's a quick ruby script which demonstrates the issue on 2.2.0dev:

url = "https://bugs.ruby-lang.org/projects/ruby-trunk/issues?set_filter=1&f[]=status_id&op[status_id]=o"
puts URI.encode(url)
URI.parse(URI.encode(url))

The output of running this script can be seen at: https://gist.github.com/lengarvey/c1d17913f9ea95fd999c

I believe a new encoder needs to be written up according to the RFC3986 spec and this should be used as the default in URI.


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #2542: URI lib should be updated to RFC 3986Closednaruse (Yui NARUSE)01/01/2010Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0