Project

General

Profile

Bug #6696

[PATCH] ERB::Util.url_encode should not escape unreserved characters

Added by madeofcode (Mark Dodwell) almost 5 years ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.2]
[ruby-core:46168]

Description

ERB::Util.url_encode is escaping tilde (~) where it should not according to the RFC.

This fixes that behaviour so that it now correctly avoids escaping all unreserved characters as per RFC 3986, Section 2.3:
http://tools.ietf.org/html/rfc3986#section-2.3

Fwiw., this is also how the Perl implementation works:
http://search.cpan.org/dist/URI/URI/Escape.pm#DESCRIPTION

I opened this issue originally on Github, but I think it warrants further discussion, so re-opening here.

erb_util_url_encode_rfc_fix.patch View (1.46 KB) madeofcode (Mark Dodwell), 07/04/2012 05:03 PM

Associated revisions

Revision 58772
Added by k0kubun (Takashi Kokubun) about 1 month ago

erb.rb: Don't encode tilde in #url_encode

Based on patch by madeofcode (Mark Dodwell).
[Bug #6696] [Fix GH-54]

~ is a unreserved character.
https://tools.ietf.org/html/rfc3986#section-2.3

History

#1 [ruby-core:46173] Updated by madeofcode (Mark Dodwell) almost 5 years ago

Sorry, somehow this ticket subject line got truncated. Newline paste fail.

#2 [ruby-core:46177] Updated by shyouhei (Shyouhei Urabe) almost 5 years ago

  • Subject changed from [PATCH] to [PATCH] ERB::Util.url_encode should not escape unreserved characters
  • Status changed from Open to Feedback

FYI, the old discussion is at https://github.com/ruby/ruby/pull/54

I see the patch itself is OK. The question is to be or not to be able to escape tilde.

#3 [ruby-core:46199] Updated by naruse (Yui NARUSE) almost 5 years ago

  • Assignee set to seki (Masatoshi Seki)
  • Status changed from Feedback to Assigned

#4 [ruby-core:46223] Updated by duerst (Martin Dürst) almost 5 years ago

The tilde was added to the unreserved characters in URIs in RFC 2396. It is specifically mentioned in http://tools.ietf.org/html/rfc2396#appendix-G.2:

The tilde "~" character was added to those in the "unreserved" set,
since it is extensively used on the Internet in spite of the
difficulty to transcribe it with some keyboards.

RFC 2396 was published in August 1998, about 14 years ago. I think it's safe to make this change now :-).

#5 [ruby-core:46224] Updated by naruse (Yui NARUSE) almost 5 years ago

This can change but need not, so up to seki, the maintainer.

やってもやらなくてもいい変更だと思っているので、関さんにお任せします。

#6 Updated by naruse (Yui NARUSE) over 4 years ago

  • Target version changed from 1.9.3 to next minor

#7 [ruby-core:81184] Updated by hsbt (Hiroshi SHIBATA) about 1 month ago

  • Assignee changed from seki (Masatoshi Seki) to k0kubun (Takashi Kokubun)

#8 [ruby-core:81213] Updated by duerst (Martin Dürst) about 1 month ago

It's now close to 19 years since RFC 2396, so please fix this issue, thanks!

#9 Updated by k0kubun (Takashi Kokubun) about 1 month ago

  • Status changed from Assigned to Closed

Applied in changeset trunk|r58772.


erb.rb: Don't encode tilde in #url_encode

Based on patch by madeofcode (Mark Dodwell).
[Bug #6696] [Fix GH-54]

~ is a unreserved character.
https://tools.ietf.org/html/rfc3986#section-2.3

Also available in: Atom PDF