Project

General

Profile

Bug #9563

URI.parse error

Added by Evgeniy Serykh about 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
ruby -v:
ruby 2.1.0p0 (2013-12-25 revision 44422)
[ruby-core:61078]

Description

I have the error for the url :

...
pry(main)> URI.parse "http://upload.wikimedia.org/wikipedia/commons/1/1c/01-Russian_alphabet-А_а.svg"
URI::InvalidURIError: bad URI(is not URI?): http://upload.wikimedia.org/wikipedia/commons/1/1c/01-Russian_alphabet-А_а.svg

My ruby version is:

$ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin13.0]

Associated revisions

Revision 46984
Added by Zachary Scott almost 2 years ago

  • lib/uri/common.rb: [DOC] [Bug #9563] Recommend using URI.escape before parsing a uri to avoid invalid characters. Reported by Evgeniy Serykh.

Revision 46984
Added by Zachary Scott almost 2 years ago

  • lib/uri/common.rb: [DOC] [Bug #9563] Recommend using URI.escape before parsing a uri to avoid invalid characters. Reported by Evgeniy Serykh.

Revision 46984
Added by Zachary Scott almost 2 years ago

  • lib/uri/common.rb: [DOC] [Bug #9563] Recommend using URI.escape before parsing a uri to avoid invalid characters. Reported by Evgeniy Serykh.

History

#1 [ruby-core:61198] Updated by Sam Rawlins about 2 years ago

You must first encode the String properly with URI.escape:

>> require 'uri'
=> true
>> URI.escape("http://upload.wikimedia.org/wikipedia/commons/1/1c/01-Russian_alphabet-А_а.svg")
=> "http://upload.wikimedia.org/wikipedia/commons/1/1c/01-Russian_alphabet-%D0%90_%D0%B0.svg"
>> URI.parse(URI.escape("http://upload.wikimedia.org/wikipedia/commons/1/1c/01-Russian_alphabet-А_а.svg"))
=> #<URI::HTTP:0x007fbe4304e468 URL:http://upload.wikimedia.org/wikipedia/commons/1/1c/01-Russian_alphabet-%D0%90_%D0%B0.svg>
>> URI.parse(URI.escape("http://upload.wikimedia.org/wikipedia/commons/1/1c/01-Russian_alphabet-А_а.svg")).to_s
=> "http://upload.wikimedia.org/wikipedia/commons/1/1c/01-Russian_alphabet-%D0%90_%D0%B0.svg"

This could be better documented.

#2 [ruby-core:61207] Updated by Zachary Scott about 2 years ago

  • Status changed from Open to Assigned
  • Assignee set to Zachary Scott
  • Category set to doc
  • Target version set to current: 2.2.0

#3 [ruby-core:64085] Updated by Zachary Scott almost 2 years ago

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

Applied in changeset r46984.


  • lib/uri/common.rb: [DOC] [Bug #9563] Recommend using URI.escape before parsing a uri to avoid invalid characters. Reported by Evgeniy Serykh.

Also available in: Atom PDF