Found a ruby bug in the URI class, what do I do?

V

Victor Pereira

Hi,

i have to open an uri with open-uri but URI is raising me an error that
an URL is an invalid uri:
URI::InvalidURIError: bad URI(is not URI?):
http://xpto.com/index.asp?action=showproduct&id={D3E21D33-6DFF-4355-9324-AE1395CEB247}
from
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/uri/common.rb:436:in
`split'
from (irb):8
from :0
That's a strange ID but valid. I even checked the RFC 2396 and {} is not
a reserved character.

Best regards,

VP
 
M

Michael Fellinger

Hi,

i have to open an uri with open-uri but URI is raising me an error that
an URL is an invalid uri:
D33-6DFF-4355-9324-AE1395CEB247}")
URI::InvalidURIError: bad URI(is not URI?):
http://xpto.com/index.asp?action=3Dshowproduct&id=3D{D3E21D33-6DFF-4355-9= 324-AE1395CEB247}
ri/common.rb:436:in
`split'
=C2=A0from (irb):8
=C2=A0from :0

That's a strange ID but valid. I even checked the RFC 2396 and {} is not
a reserved character.

Best regards,

Just file a bug at http://redmine.ruby-lang.org/ so it won't be forgotten.
If you also supply a patch against the uri lib, you get bonus points :)

--=20
Michael Fellinger
CTO, The Rubyists, LLC
972-996-5199
 
R

Rob Biedenharn

But it is part of the 'unwise' set defined by RFC 2396 in:
"2.4.3. Excluded US-ASCII Characters
Although they are disallowed within the URI syntax, we include
here a description of those US-ASCII characters that have been
excluded and the reasons for their exclusion."
http://www.faqs.org/rfcs/rfc2396.html

Just because a URI works in any (or even all) browser(s) doesn't mean
that it conforms to the standard for URIs.

I think that URI.split is doing the right thing.

URI.escape() might be a workaround for you:

irb> u="http://xpto.com/index.asp?
action=showproduct&id={D3E21D33-6DFF-4355-9324-AE1395CEB247}"
=> "http://xpto.com/index.asp?
action=showproduct&id={D3E21D33-6DFF-4355-9324-AE1395CEB247}"
irb> URI.escape(u)
=> "http://xpto.com/index.asp?action=showproduct&id={D3E21D33-6DFF-4355-9324-AE1395CEB247}
"
irb> u1=URI.parse(URI.escape(u))
=> #<URI::HTTP:0x38cbd8 URL:http://xpto.com/index.asp?action=showproduct&id={D3E21D33-6DFF-4355-9324-AE1395CEB247}irb> u1.query
=> "action=showproduct&id=%7BD3E21D33-6DFF-4355-9324-AE1395CEB247%7D"
irb> URI.unescape(u1.query)
=> "action=showproduct&id={D3E21D33-6DFF-4355-9324-AE1395CEB247}"


-Rob
Just file a bug at http://redmine.ruby-lang.org/ so it won't be
forgotten.
If you also supply a patch against the uri lib, you get bonus
points :)

Rob Biedenharn http://agileconsultingllc.com
(e-mail address removed)
 
V

Victor Pereira

Rob,

to be in the 'unwise' doesn't mean
that it not conforms to the standard for URIs.

I'm escaping and it works, but in my option it could be handled by the
lib.

VP
 
R

Rob Biedenharn

Sorry, Victor, but yes it does.

Quoting from the end of RFC 2396 section 2.4.3:

Other characters are excluded because gateways and other transport
agents are known to sometimes modify such characters, or they are used
as delimiters.
unwise = "{" | "}" | "|" | "\" | "^" | "[" | "]" | "`"
Data corresponding to excluded characters must be escaped in order to
be properly represented within a URI.

So that last sentence pretty much nails it. Curly braces "...must be
escaped in order to be properly represented within a URI."

So you'll have to continue to escape them yourself. It wouldn't be
right for the URI class to depart from the standard here.

-Rob

Rob,

to be in the 'unwise' doesn't mean
that it not conforms to the standard for URIs.

I'm escaping and it works, but in my option it could be handled by the
lib.

VP

Rob Biedenharn http://agileconsultingllc.com
(e-mail address removed)
+1 513-295-4739
Skype: rob.biedenharn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,965
Messages
2,570,148
Members
46,710
Latest member
FredricRen

Latest Threads

Top