Project

General

Profile

Feature #4551

uri.set_scheme should downcase schemes

Added by drbrain (Eric Hodel) about 8 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:35606]

Description

=begin
From RFC 2396 section 3.1:

"For resiliency, programs interpreting URI should treat upper case letters as equivalent to lower case in scheme names (e.g., allow 'HTTP' as well as 'http')."

Currently programs using URI for HTTP vs HTTPS protocol check which protocol to use with a comparison like:

http.use_ssl = uri.scheme == 'https'

Since URI does not modify the input scheme this makes the check fragile. For example:

URI.parse('httpS://example').scheme # => "httpS"

Since RFC 2396 allows uppercase letters to be treated like lowercase I think #set_scheme should downcase its value.
=end


Files

uri.rb.scheme_downcase.patch (929 Bytes) uri.rb.scheme_downcase.patch drbrain (Eric Hodel), 04/04/2011 07:35 AM

Associated revisions

Revision 65573857
Added by drbrain (Eric Hodel) about 7 years ago

  • lib/uri/generic.rb (module URI): URI now downcases the scheme to follow RFC 2396 section 3.1. [ruby-trunk - Feature #4551]
  • test/uri/test_generic.rb (class URI): Test for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 35305
Added by drbrain (Eric Hodel) about 7 years ago

  • lib/uri/generic.rb (module URI): URI now downcases the scheme to follow RFC 2396 section 3.1. [ruby-trunk - Feature #4551]
  • test/uri/test_generic.rb (class URI): Test for above

Revision 35305
Added by drbrain (Eric Hodel) about 7 years ago

  • lib/uri/generic.rb (module URI): URI now downcases the scheme to follow RFC 2396 section 3.1. [ruby-trunk - Feature #4551]
  • test/uri/test_generic.rb (class URI): Test for above

Revision 35305
Added by drbrain (Eric Hodel) about 7 years ago

  • lib/uri/generic.rb (module URI): URI now downcases the scheme to follow RFC 2396 section 3.1. [ruby-trunk - Feature #4551]
  • test/uri/test_generic.rb (class URI): Test for above

Revision 35305
Added by drbrain (Eric Hodel) about 7 years ago

  • lib/uri/generic.rb (module URI): URI now downcases the scheme to follow RFC 2396 section 3.1. [ruby-trunk - Feature #4551]
  • test/uri/test_generic.rb (class URI): Test for above

Revision 35305
Added by drbrain (Eric Hodel) about 7 years ago

  • lib/uri/generic.rb (module URI): URI now downcases the scheme to follow RFC 2396 section 3.1. [ruby-trunk - Feature #4551]
  • test/uri/test_generic.rb (class URI): Test for above

Revision 35305
Added by drbrain (Eric Hodel) about 7 years ago

  • lib/uri/generic.rb (module URI): URI now downcases the scheme to follow RFC 2396 section 3.1. [ruby-trunk - Feature #4551]
  • test/uri/test_generic.rb (class URI): Test for above

History

Updated by naruse (Yui NARUSE) about 8 years ago

=begin
Your point is reasonable, but it breaks some cases like
s = 'HTTP://example.com/'
URI(s).to_s == s
=end

Updated by naruse (Yui NARUSE) about 7 years ago

  • Description updated (diff)
  • Status changed from Open to Assigned
  • Assignee set to naruse (Yui NARUSE)

Updated by naruse (Yui NARUSE) about 7 years ago

  • Assignee changed from naruse (Yui NARUSE) to drbrain (Eric Hodel)

I agree with this.
Please commit it.

#4

Updated by drbrain (Eric Hodel) about 7 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r35305.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/uri/generic.rb (module URI): URI now downcases the scheme to follow RFC 2396 section 3.1. [ruby-trunk - Feature #4551]
  • test/uri/test_generic.rb (class URI): Test for above

Also available in: Atom PDF