Project

General

Profile

Actions

Bug #13406

closed

URI.parse

Added by shahkrunalm (Krunal Shah) about 7 years ago. Updated about 7 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:80591]

Description

Previously we were using

ruby '2.1.9'
rails '4.1.1'

uri = URI.parse("http://" + 'abc.com') # Here, domain name abc.com is provided using single quotation.

This was throwing exception as domain name is invalid as it contain single quotation and that's what we want

Following is the stack trace

2.1.9 :001 > a = '\'abc.com\''
 => "'abc.com'" 
2.1.9 :002 > URI.parse("http://" + a)
URI::InvalidURIError: the scheme http does not accept registry part: 'abc.com' (or bad hostname?)
	from /usr/local/rvm/rubies/ruby-2.1.9/lib/ruby/2.1.0/uri/generic.rb:214:in `initialize'
	from /usr/local/rvm/rubies/ruby-2.1.9/lib/ruby/2.1.0/uri/common.rb:214:in `new'
	from /usr/local/rvm/rubies/ruby-2.1.9/lib/ruby/2.1.0/uri/common.rb:214:in `parse'
	from /usr/local/rvm/rubies/ruby-2.1.9/lib/ruby/2.1.0/uri/common.rb:747:in `parse'
	from (irb):2
	from /usr/local/rvm/gems/ruby-2.1.9@clearstream/gems/railties-4.1.1/lib/rails/commands/console.rb:90:in `start'
	from /usr/local/rvm/gems/ruby-2.1.9@clearstream/gems/railties-4.1.1/lib/rails/commands/console.rb:9:in `start'
	from /usr/local/rvm/gems/ruby-2.1.9@clearstream/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:69:in `console'
	from /usr/local/rvm/gems/ruby-2.1.9@clearstream/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
	from /usr/local/rvm/gems/ruby-2.1.9@clearstream/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
	from bin/rails:8:in `require'
	from bin/rails:8:in `<main>'

Now, we have upgraded to

ruby '2.4.1'
rails '5.0.2'

uri = URI.parse("http://" + 'abc.com') 

Now, it doesn't throw any exception and allows domain name with single quotation.

2.4.1 :005 > a = '\'abc.com\''
 => "'abc.com'" 
2.4.1 :006 > URI.parse("http://" + a)
 => #<URI::HTTP http://'abc.com'> 
2.4.1 :007 > 
Actions #1

Updated by shyouhei (Shyouhei Urabe) about 7 years ago

  • Description updated (diff)

Updated by naruse (Yui NARUSE) about 7 years ago

  • Status changed from Open to Rejected

Unfortunately RFC3986 allows "'" in host.

   authority     = [ userinfo "@" ] host [ ":" port ]
   host          = IP-literal / IPv4address / reg-name
   reg-name      = *( unreserved / pct-encoded / sub-delims )
   sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
                 / "*" / "+" / "," / ";" / "="
Actions

Also available in: Atom PDF

Like0
Like0Like0