NET-A-PORTER/scala-uri

Hostnames containing anything other than alphanumerics and periods should fail

Closed this issue · 3 comments

scala> val hostWithComma = parse("http://www.test,com").toURI
hostWithComma: java.net.URI = http://www.test,com

java.net.URI allows this, but I guess that isn't really a guiding light.

"The Internet standards (Requests for Comments) for protocols mandate that component hostname labels may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner), the digits '0' through '9', and the hyphen ('-'). The original specification of hostnames in RFC 952, mandated that labels could not start with a digit or with a hyphen, and must not end with a hyphen. However, a subsequent specification (RFC 1123) permitted hostname labels to start with digits. No other symbols, punctuation characters, or white space are permitted."

http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names

theon commented

Hi,

Thanks for raising this. I had a look into rfc3986, which I have been trying to follow. rfc3986 does allow commas in the host:

sub-delims  = "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "="
reg-name    = *( unreserved / pct-encoded / sub-delims )
host             = IP-literal / IPv4address / reg-name

This does conflict with rfc1123 you quoted, however unless it is causing anyone any problems, I think I would rather be permissive here incase anyone needs it.

Hehe, the inconsistencies of the URI specs never cease to amaze me.. But I guess it's not unreasonable to allow commas in hostnames then.

Closing this as 3986 supersedes 1123