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.
Comment | File | Size | Author |
---|---|---|---|
#19 | interdiff-1993920-12-19.txt | 6.31 KB | lwalley |
#19 | link-allow-tel-links-1993920-19.patch | 3.54 KB | lwalley |
| |||
#12 | interdiff-1993920-10-12.txt | 3.77 KB | lwalley |
#12 | link-allow-tel-links-1993920-12.patch | 4.27 KB | lwalley |
#10 | link.allow-tel-links-1993920-10.patch | 1.51 KB | weri |
Comments
Comment #1
jcfiala CreditAttribution: jcfiala commentedActually, no patch is needed.
The list of allowed protocols is a Drupal variable - filter_allowed_protocols. Currently you can see it being used around line 1141 of link.module, as such:
$allowed_protocols = variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal'));
If you change the value of filter_allowed_protocols to include 'tel', then it should work fine. I would suggest setting it as a $conf setting in your settings.php myself, or set it inside of a module update hook.
Comment #2
johnnybgoode CreditAttribution: johnnybgoode commentedHi, It appears that with the current url validation in the link module, in addition to adding 'tel' to the 'filter_allowed_protocols' variable, a patch is needed to support tel: links. A fairly straightforward patch is attached and I can confirm it is working with link-7.x-1.x dev running under drupal 7.34.
Comment #3
johnnybgoode CreditAttribution: johnnybgoode commentedChanging issue status for testbot
Comment #5
johnnybgoode CreditAttribution: johnnybgoode commentedChanging version for testbot
Comment #6
Dragan Eror CreditAttribution: Dragan Eror commentedHere is updated patch... (diff made according: branch 7.x-1.x and commit 71cddd958bce9a68a0a4316b2ef6bf3966e1a3e3).
Added 'tel' protocol to $allowed_protocols array.
Created $tel_pattern according international phone number format E 164 (http://en.wikipedia.org/wiki/E.164).
Condition checks for $allowed_protocols and $tel_pattern and returns link as external.
Comment #7
Etroid CreditAttribution: Etroid commentedI do think comment #6 provides the most accurate solution. However, given that the international phone number format E 164 can only have a maximum of 15 digits, shouldn't the pattern be as follows:
The national destination code can only have up to 14 digits with a country code of 1 digit. This gives a total of 15 digits
Comment #8
idebr CreditAttribution: idebr at One Shoe commentedComment #9
jsst CreditAttribution: jsst at Ibuildings commentedPatch works as advertised. Note: you must disable URL validation for the field because that only works for real URLs.
Comment #10
weri CreditAttribution: weri at Previon Plus AG commentedAs Etroid mentioned, the whole number should have a maximum of 15 characters. I updated the patch from Dragan Eror.
Comment #12
lwalley CreditAttribution: lwalley commentedWithout using something like Google's libphonenumber library, validation of phone numbers is going to be difficult. However, I think it would be good to retain the URL validation for the other protocols. So, I've updated the patch from #10 to include a new link type LINK_TEL and adjusted the regex slightly to allow numbers starting with 0, which is common for local numbers in e.g. the United Kingdom. To achieve this, I split the regex into two options, one that allows the value to start with +[1-9] (which I assume was the intention of the original requirement for non-zero number, since I don't think there are any international codes starting with 0, but I could be wrong), and the other that allows the value to start with [0-9]. The value is limited to 15 digits.
I'm sure there are many improvements that can be made to this, but at a minimum this patch allows URL validation to remain on for the link field, and adds some basic tests. Patch and interdiff with #10 attached.
Comment #13
lwalley CreditAttribution: lwalley commentedComment #15
lwalley CreditAttribution: lwalley commentedFailing tests are possibly unrelated. Looks like there is an issue with how link field is being added to node type in the tests. Current tests are adding link field to node type through the UI. Unsure of the original intention for doing it through the UI, i.e. whether it is intended to actually test the UI, or if its just for setup. If just for setup, then could maybe be switched to use field_create_field and field_create_instance e.g. something like how ListFieldUITestCase::createListField does it.
Comment #16
idebr CreditAttribution: idebr commented@Iwalley all tests for the Link module are currently failing. There is an open issue to fix them: #2843813: Fix failing tests due to missing 'administer fields' permission
Comment #17
lwalley CreditAttribution: lwalley commentedAh, that explains that then, thanks.
Comment #18
dandaman CreditAttribution: dandaman at August Ash commentedA client wanted us to allow the links to certain types of extensions on the end of the link, although in some browsers or OSes these are not fully supported. So I changed the regular expression in the patch to this:
I'm not that good at reading these IETF specifications, but it at least supports some common post-phone-number items as specified here: https://tools.ietf.org/html/rfc2806#section-2.2
The patch also worked for us, thanks!
Comment #19
lwalley CreditAttribution: lwalley commentedRe-roll patch from #12 against link 7.x-1.x.
Comment #20
dqdPatch looks good. I would like to read about another reviewer before RTBC. Anyone?
Comment #21
alex_optimWorks fine for me.
Comment #22
pifagorComment #24
pifagor