Project

General

Profile

Actions

Bug #10507

closed

URI Error: bad URI(is not URI?) in Ruby 2.0.0, 2.1.5, 2.2.0preview1

Added by JuanitoFatas (Juanito Fatas) almost 10 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
2.1.5p273
[ruby-core:66267]

Description

This url is used to get a screenshot from a web service and specify the dimensions.

Ruby 2.0.0p598

ruby -v -ruri -e "URI 'http://localhost:3000/?url=google.com&clipRect={"top":0,"left":0,"width":1050,"height":700}'"
ruby 2.0.0p598 (2014-11-13) [x86_64-darwin13.3.0]
/Users/Juan/.rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/uri/common.rb:176:in `split': bad URI(is not URI?): http://localhost:3000/?url=google.com&clipRect={top:0,left:0,width:1050,height:700} (URI::InvalidURIError)
	from /Users/Juan/.rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/uri/common.rb:211:in `parse'
	from /Users/Juan/.rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/uri/common.rb:747:in `parse'
	from /Users/Juan/.rubies/ruby-2.0.0-p598/lib/ruby/2.0.0/uri/common.rb:996:in `URI'
	from -e:1:in `<main>'

Ruby 2.1.5p273

$ ruby -v -ruri -e "URI 'http://localhost:3000/?url=google.com&clipRect={"top":0,"left":0,"width":1050,"height":700}'"
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin13.0]
/Users/Juan/.rubies/ruby-2.1.5/lib/ruby/2.1.0/uri/common.rb:176:in `split': bad URI(is not URI?): http://localhost:3000/?url=google.com&clipRect={top:0,left:0,width:1050,height:700} (URI::InvalidURIError)
	from /Users/Juan/.rubies/ruby-2.1.5/lib/ruby/2.1.0/uri/common.rb:211:in `parse'
	from /Users/Juan/.rubies/ruby-2.1.5/lib/ruby/2.1.0/uri/common.rb:747:in `parse'
	from /Users/Juan/.rubies/ruby-2.1.5/lib/ruby/2.1.0/uri/common.rb:1232:in `URI'
	from -e:1:in `<main>'

Ruby 2.2.0preview1

$ ruby -v -ruri -e "URI 'http://localhost:3000/?url=google.com&clipRect={"top":0,"left":0,"width":1050,"height":700}'"
ruby 2.2.0preview1 (2014-09-17 trunk 47616) [x86_64-darwin13]
/Users/Juan/.rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/uri/rfc3986_parser.rb:47:in `split': bad URI(is not URI?): http://localhost:3000/?url=google.com&clipRect={top:0,left:0,width:1050,height:700} (URI::InvalidURIError)
	from /Users/Juan/.rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/uri/rfc3986_parser.rb:53:in `parse'
	from /Users/Juan/.rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/uri/common.rb:226:in `parse'
	from /Users/Juan/.rubies/ruby-2.2.0-preview1/lib/ruby/2.2.0/uri/common.rb:713:in `URI'
	from -e:1:in `<main>'

Thank you!

Updated by JuanitoFatas (Juanito Fatas) almost 10 years ago

Encode + URI + open.

ruby -v -ruri -e "open(URI(URI.encode 'http://localhost:3000/?url=google.com&clipRect={"top":0,"left":0,"width":1050,"height":700}'))"
ruby 2.0.0p598 (2014-11-13) [x86_64-darwin13.3.0]
-e:1:in `<main>': warning: URI.escape is obsolete
-e:1:in `open': no implicit conversion of URI::HTTP into String (TypeError)
	from -e:1:in `<main>'

ruby -v -ruri -e "open(URI(URI.encode 'http://localhost:3000/?url=google.com&clipRect={"top":0,"left":0,"width":1050,"height":700}'))"
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin13.0]
-e:1:in `<main>': warning: URI.escape is obsolete
-e:1:in `open': no implicit conversion of URI::HTTP into String (TypeError)
	from -e:1:in `<main>'

ruby -v -ruri -e "open(URI(URI.encode 'http://localhost:3000/?url=google.com&clipRect={"top":0,"left":0,"width":1050,"height":700}'))"
ruby 2.2.0preview1 (2014-09-17 trunk 47616) [x86_64-darwin13]
-e:1:in `<main>': warning: URI.escape is obsolete
-e:1:in `open': no implicit conversion of URI::HTTP into String (TypeError)
	from -e:1:in `<main>'

Updated by jeremyevans0 (Jeremy Evans) over 5 years ago

  • Status changed from Open to Closed

This was fixed between 2.1 and 2.2:

$ ruby21 -ruri -e "p URI 'http://localhost:3000/?url=google.com&clipRect={"top":0,"left":0,"width":1050,"height":700}'"    
/usr/local/lib/ruby/2.1/uri/common.rb:176:in `split': bad URI(is not URI?): http://localhost:3000/?url=google.com&clipRect={top:0,left:0,width:1050,height:700} (URI::InvalidURIError)
        from /usr/local/lib/ruby/2.1/uri/common.rb:211:in `parse'
        from /usr/local/lib/ruby/2.1/uri/common.rb:747:in `parse'
        from /usr/local/lib/ruby/2.1/uri/common.rb:1232:in `URI'
        from -e:1:in `<main>'

$ ruby22 -ruri -e "p URI 'http://localhost:3000/?url=google.com&clipRect={"top":0,"left":0,"width":1050,"height":700}'" 
#<URI::HTTP http://localhost:3000/?url=google.com&clipRect={top:0,left:0,width:1050,height:700}>
Actions

Also available in: Atom PDF

Like0
Like0Like0