Hassan Schroeder wrote:
> On Thu, Nov 20, 2008 at 2:16 PM, Ben Johnson <bjohnson / binarylogic.com> 
> wrote:
> 
>>>> URI.parse("http://whatever_again.domain.com")
>> URI::InvalidURIError: the scheme http does not accept registry part:
>> whatever_again.domain.com (or bad hostname?)
> 
>> When you add an underscore the sub domain it raises an exception, even
>> though that is a perfectly valid host name.
> 
> No, it's not. Check the DNS RFCs: A-Z, a-z, 0-9 and the hyphen are
> the only legal characters.

That's not strictly a DNS limitation. However there are old (pre-DNS) 
RFCs that say those are the only legal characters in a "hostname".

The key DNS RFCs are 1034 and 1035. RFC 1034 gives a very liberal 
definition of a domain name (binary labels, each 1 to 63 bytes long, 
maximum 255 bytes in total)

However it then makes a recommendation:

"3.5. Preferred name syntax

The DNS specifications attempt to be as general as possible in the rules
for constructing domain names.  The idea is that the name of any
existing object can be expressed as a domain name with minimal changes.
However, when assigning a domain name for an object, the prudent user
will select a name which satisfies both the rules of the domain system
and any existing rules for the object, whether these rules are published
or implied by existing programs.

For example, when naming a mail domain, the user should satisfy both the
rules of this memo and those in RFC-822.  When creating a new host name,
the old rules for HOSTS.TXT should be followed.  This avoids problems
when old software is converted to use domain names.

The following syntax will result in fewer problems with many
applications that use domain names (e.g., mail, TELNET)."

(then gives a BNF description of letters/digits/hyphens)

In practice - there *are* hosts out there which have underscores in 
their hostnames, so a library which forbids this on the basis of ancient 
HOSTS.TXT rules causes real problems.

RFC 2822 (for E-mail addresses) is much more liberal.
-- 
Posted via http://www.ruby-forum.com/.