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).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jcfiala’s picture

I 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.

DamienMcKenna’s picture

Title: Make URL validation optional » Support custom TLDs from the current hostname

Refocusing this issue: the module should also allow the site's current hostname as a valid domain, regardless of TLD.

dqd’s picture

@ DamienMcKenna: did you check latest dev already?

MrHaroldA’s picture

The link module prevents users from adding internal links, because .lan is not a valid TLD.

Although .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 a variable_get() would be sufficient in our case...

dqd’s picture

Status: Needs review » Closed (works as designed)

I 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 ...

MrHaroldA’s picture

Well, 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...

firfin’s picture

Version: 7.x-1.0-alpha3 » 7.x-1.0
Status: Closed (works as designed) » Active

I 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 :

  • .localhost
  • .test
  • .invalid
  • .example

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

manarth’s picture

.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.

DamienMcKenna’s picture

The .local TLD is used on OSX's Bonjour networking system and others, thus should validate.

firfin’s picture

Thanks 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.

mr.york’s picture

Status: Active » Needs work
FileSize
1.38 KB

Need UI.

jcfiala’s picture

The only 'official' TLDs for internal testing seem to come from RFC2606 :

.localhost
.test
.invalid
.example
None of this are correctly validated by the link module btw.

Well, 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.

jcfiala’s picture

Status: Needs work » Fixed

You 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.