reddit/reddit — Issue #289: Reddit doesn't allow hostnames containing underscore
Author: lambda
Created: 2011-12-16 08:55:38+00:00
State: open

When submitting URLs, Reddit appears to reject hostnames that contain an underscore (`_`). While `_` is technically forbidden from hostnames by [RFC 1123](http://tools.ietf.org/html/rfc1123), it is allowed by [DNS](http://tools.ietf.org/html/rfc2181#section-11), which specifies only that higher level protocols may impose their own syntactic restrictions on domain or host names. HTTP defers to the generic URI syntax, [RFC 2396](http://tools.ietf.org/html/rfc2396), which is obsoleted by [RFC 3896](http://tools.ietf.org/html/rfc3986), which imposes almost no restrictions on the hostname (and allows for URI encoding anything that you can't otherwise put in the host name). It does mention the standard letter, digit, hyphen restrictions for DNS based host names, but specifies that other types of host names may contain other character.

It seems that it's relatively common for host names to contain underscores. There are [lots](https://bugzilla.mozilla.org/show_bug.cgi?id=89945) of [bug](https://issues.apache.org/bugzilla/show_bug.cgi?id=21133) [reports](https://bugzilla.redhat.com/show_bug.cgi?id=646913) for other software complaining that they don't support underscores in host names (and most of them are resolved by allowing underscores). And when I looked through Alexa's ["Top Million Sites" CSV](http://s3.amazonaws.com/alexa-static/top-1m.csv.zip) (not a perfect data set, but one that's somewhat representative), I found more than a dozen that contained an underscore in their host name.

This bug has been [previously reported and closed](http://code.reddit.com/ticket/678), but I think that it deserves another look. While technically invalid, in practice, it seems that underscores are allowed in hostnames by most software. And it's [still tripping up](http://www.reddit.com/r/boston/comments/neb4h/boston_hockey_player_didnt_get_kicked_from_the/c38emxu) people who are trying to post links to Reddit, such that they have to use URL shorteners as Reddit rejects the link.