Bugs: Browse | Submit New | Admin

[#1890] URI.parse fails to encode/decode IPv6 addresses

Date:
2005-05-10 02:03
Priority:
3
Submitted By:
Sam Roberts (sam)
Assigned To:
Akinori MUSHA (knu)
Category:
Network / Comm / Protocols
State:
Open
Platform:
 
Summary:
URI.parse fails to encode/decode IPv6 addresses

Detailed description
irb(main):002:0> URI.parse("http://[::1]").host
=> "[::1]"
irb(main):003:0> Socket.getaddrinfo("[::1]", nil)
SocketError: getaddrinfo: No address associated with nodename
  from (irb):3:in `getaddrinfo'
  from (irb):3
 
 
I think that URI should remove the [] from the host part when it parses,
and add it back in when it builds.
 
I see this problem propogates itself up through net/http, open-uri, 
etc... None of these APIs seem to accept IPv6 URIs (at least not ::1,
loopback, the only one I can connect to).
 
 
It also won't encode IPv6 addresses:
 
URI::HTTP.build(:scheme => 'http', :host => '::1').to_s
URI::InvalidComponentError: bad component(expected host component): ::1
  from /usr/local/lib/ruby/1.8/uri/generic.rb:380:in `check_host'
  ...
 
This works:
 
  URI::HTTP.build(:scheme => 'http', :host => '[::1]').to_s)
  => "http://[::1]"
 
But it's URI's job to know the IPv6 URI syntax, not mine!

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-05-29 17:24
Sender: Sam Roberts

The previous description was complete, including how to 
reproduce, and the problem still exists in trunk:

/svn-ruby-1.8% ./ruby -Ilib -ruri -e 'p 
URI.parse("http://[::1]").host'
"[::1]"
Date: 2006-11-02 07:19
Sender: Ryan Davis

I'm closing this bug due to its age / staleness. I simply can't
triage them all and I have
to cut corners somewhere. If you believe this bug still exists
in the latest version of
ruby 1.8.x, please reopen it and, if you can, attach a minimally
reproducible test case
to help us repro it in 1.8.x (where x >= 5).

Thank you for your support. Things will get better.

Ryan Davis.

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
assigned_tonone2007-06-12 02:25zenspider
category_idMisc / Other Standard Library2007-05-29 16:26zenspider
status_idClosed2007-03-17 01:27sam
status_idOpen2006-11-02 07:19zenspider
resolution_idNone2006-11-02 07:19zenspider
close_date2006-11-02 07:192006-11-02 07:19zenspider