discourse/app
Julien Ma dcb0e5f1e5 Fix "Host is invalid" error when TLD >10 chars (#7948)
Related to https://meta.discourse.org/t/host-is-invalid-error-when-tld-is-longer-than-7-characters/46081.

Using Discourse `v2.4.0.beta2 +119`, I can't add an host (when embedding, cf. `/admin/customize/embedding`) ending with `.engineering`.
Turns out current regex limits to 10 characters.

Fix is dumb: it only allows for up to 24 chars, which is the **current** max TLD length, see https://stackoverflow.com/a/22038535/1907212.

---

Maybe a better (and longer-term) fix would be to allow for up to 64 chars, which I understand comes from the RFC.
I'm not at ease with regexes, so can't be sure about it, but [this suggestion](https://meta.discourse.org/t/host-is-invalid-error-when-tld-is-longer-than-7-characters/46081/8?u=julienma) seems pretty good:

> 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.
2019-07-26 16:29:48 -04:00
..
assets DEV: Display FA 4.7 deprecation notice in all environments 2019-07-26 15:25:20 -04:00
controllers FIX: Better error when SSO fails due to blank secret (#7946) 2019-07-26 17:37:23 +03:00
helpers FIX: Fallback to gzip compression if brotli isn't supported (#7895) 2019-07-16 11:05:37 -03:00
jobs DEV: Refactor helper methods for upload markdown 2019-07-25 16:36:35 +02:00
mailers SECURITY: Strip HTML from invite emails 2019-07-05 14:57:11 -04:00
models Fix "Host is invalid" error when TLD >10 chars (#7948) 2019-07-26 16:29:48 -04:00
serializers FEATURE: Allow viewing of raw emails for reviewable queued posts (#7910) 2019-07-19 11:56:14 -04:00
services FEATURE: Watched words improvements (#7899) 2019-07-22 14:59:56 +03:00
views add user avatar to user crawler layout (#7917) 2019-07-22 10:52:35 -04:00