Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm working on an intranet site, where all the LAN domains use the format foo.bar.lan.
The link module prevents users from adding internal links, because .lan is not a valid TLD.
This patch allows administrators to make URL validation optional (but defaults to require-validation, to avoid changing the current default behaviour).
Comment | File | Size | Author |
---|---|---|---|
#11 | 1179944-11-support-custom-tlds.patch | 1.38 KB | mr.york |
link.make_url_validational_optional.patch | 1.39 KB | manarth | |
Comments
Comment #1
jcfiala CreditAttribution: jcfiala commentedI hate to say it after you've gone through all this work, but have you checked the dev version? I've got optional url validation there.
That being said, the idea of having custom tld isn't a bad one.
Comment #2
DamienMcKennaRefocusing this issue: the module should also allow the site's current hostname as a valid domain, regardless of TLD.
Comment #3
dqd@ DamienMcKenna: did you check latest dev already?
Comment #4
MrHaroldA CreditAttribution: MrHaroldA commentedAlthough .lan isn't a valid TLD, I'd really like to be able to use it in a link field as we use it for local machines and internal servers.
Expanding
LINK_DOMAINS
with avariable_get()
would be sufficient in our case...Comment #5
dqdI still don't get it. You can turn off URL validation in link module since ages. Why don't you simply turn it off? If you want to use custom urls with fantasy strings, I don't understand what this issue here is for, nor for what you need url validating then turned on or worked around with any patch?
URL validating is for "VALID" urls, thats what it is for namely and will ever be. If your hostname is home_kitchen#+ß09990ß//-### you simply can't use URL validation.
If you want a custom string validation tool for your custom enviroment, feel free to open an issue for that, but URL validation works as designed.
Sorry, and thanks for understanding ...
Comment #6
MrHaroldA CreditAttribution: MrHaroldA commentedWell, I'd like our users to put in a TLD of their choice, but it does have to be formatted like a url: 'http://domain.tld|local|lan'
Without nagging: an option to use Drupal's
valid_url()
instead of link's url validator will suffice...Comment #7
firfin CreditAttribution: firfin commentedI stumbled upon this too using the 7.x-1.0 release. In my case it was .dev domains not validating ('not a valid url'). Still the same for .lan domain names. But .local domains were approved by the module. This is very confusing. None of the three are valid TLDs afaik.
The only 'official' TLDs for internal testing seem to come from RFC2606 :
None of this are correctly validated by the link module btw.
While turning of validation is a way of circumventing this problem, it seems sub-optimal. Allowing usage of the current hostname makes sense to me.
That being said, I think this is very closely related or even duplicate of #1318938: An all-embracing attempt for URL validation and Input / Output Form Filtering
Comment #8
manarth CreditAttribution: manarth commented.local
is the domain defined for use by mDNS (Multicast DNS) - a type of local network peer-to-peer name resolution that doesn't require a DNS server…which is probably why.local
is permitted by the link module.Comment #9
DamienMcKennaThe .local TLD is used on OSX's Bonjour networking system and others, thus should validate.
Comment #10
firfin CreditAttribution: firfin commentedThanks for your response manarth and damian.
So basically a pseudo-TLD validates fine by the link module (, probably because it was patched in by someone who needed it long ago? )
But the specially reserved TLDs do not pass Link's validation?
After reading up on the subject I surmise that using .local is bad. As is using .dev or even .lan
From now on I will be using ( third and fourth level ) subdomains from self-owned TLDs.
Seems to be best practice, so ... problem solved :-D
It would of course be easy to patch in the 'official' TLDs that are reserved for testing / local use. But I doubt that is wanted atm, with the ongoing discussion about validation.
Comment #11
mr.york CreditAttribution: mr.york commentedNeed UI.
Comment #12
jcfiala CreditAttribution: jcfiala commentedWell, you know, the use of those tlds don't seem to be something you'ld use with the link module, reading over what the TLDs are for.
Comment #13
jcfiala CreditAttribution: jcfiala commentedYou missed a use of LINK_DOMAINS, so after applying your patch, mr.york, I ended up creating a _link_domains() function.
That said, this looks good, and I've added it.