"Host is invalid" error when TLD is longer than 7 characters

It does not pass the Armenian localized domain in the first post:

.xn–y9a3aq

I cannot find any active domains in that TLD however for iframely test. ICANN names a Persian TLD and site: http://نمونہ.آزمایشی (http://xn–hhbbbh02d.xn–hgbk6aj7f53bba) which also does not appear to have actually be in use, but gives a more extreme example, and one presumably that should be supported.

My, from memory, understanding of the rules of DNS labels are:

All labels are 1 to 63 characters, case insensitive A to Z, 0 to 9 and - (hyphen), all from ASCII.
No labels may start with a hyphen.
No top level domain label may start with a number.

That means a regexp for a valid domain name would look like:

/^([a-z0-9][a-z0-9-]{0,62}\.)+[a-z][a-z0-9-]{0,62}\.?$/

Domains that are just a TLD are sufficiently bizarre as to be worth ignoring.