mydnshost / mydnshost-api

API Backend for mydnshost
Other
2 stars 1 forks source link

Most punicode TLDs don't work #126

Closed csmith closed 3 years ago

csmith commented 3 years ago

The regex here:

https://github.com/mydnshost/mydnshost-api/blob/88d5dade9c8cb9ea175f32d97d1877456375c237/classes/domain.php#L655

Kinda allows for punicode TLDs (it has an xn-- option) but then doesn't allow numbers which stops almost all of them working.

I think this would work:

#^((?=[_a-z0-9-]{1,63}\.)(xn--)?[_a-z0-9]+(-[_a-z0-9]+)*\.)+(xn--)?[a-z0-9]{2,63}$#i

But that would also allow numerics in non-punicode-TLDs. I'm not sure if that's an issue? If you want to explicitly preclude that then can ugly it up like this, I guess:

#^((?=[_a-z0-9-]{1,63}\.)(xn--)?[_a-z0-9]+(-[_a-z0-9]+)*\.)+(xn--[a-z0-9]{2,63}|[a-z]{2,63})$#i

(Regexes untested. Not my fault if they become sentient and eat your face.)