From: tamouse mailing lists Date: 2012-12-04T03:25:20+09:00 Subject: Re: Found a ruby bug in the URI class, what do I do? On Sun, Dec 2, 2012 at 4:00 PM, David Madison wrote: > tamouse mailing lists wrote in post #1087523: >> Handling an underscore in a domain name as you are is expedient to the >> immediate issue you seem to have, however it is not a fix. > > Well - it's not a proper fix from the perspective that URI is broken > and needs to be rethought, but it is a fix to the problem of: > "I am using URI and I need to support sub_domain names and it > looks like the maintainers of URI aren't planning on changing > anytime soon" > > :) > > -- > Posted via http://www.ruby-forum.com/. > This might offer a better workaround: Change the regexp used to parse the hostname by creating a new parser object: 1.9.3-p194 :047 > u = URI::Parser.new(:HOSTNAME => "(?:[a-zA-Z0-9\\-._~]|%\\h\\h)+") => # 1.9.3-p194 :048 > uri = u.parse("http://www_w.example.com") => # Interesting thing, I was perusing the commit logs for uri/common.rb. On Dec 5th, 2010, a change was applied that would have made the hostname regexp match that specified in 3986, then about 1.5 hours later, it was changed back. I wonder what their thinking was...