Problem/Motivation
It is typical these days to type eg. Lean@Tieto. When the "Convert URLs into links" option is enabled in the filter settings, the link gets converted into an email address even though it is not a complete email address(without ".com" present in them) .
Proposed resolution
Require email address patterns to have at least one subdomain, since emails are usually with subdomain. This allows for the conventional discussion forms like 'working@home today'. Patches available.
Remaining tasks
Patch for both D8 & D7 available.
User interface changes
None
API changes
None
Comment | File | Size | Author |
---|---|---|---|
#104 | d7-email-tld-requirement-104.patch | 3.42 KB | douggreen |
#97 | d8-email-tld-requirement-97.patch | 3.42 KB | mark_fullmer |
#97 | interdiff-2016739-92-97.txt | 3.47 KB | mark_fullmer |
#86 | 2016739-86.patch | 2.8 KB | ayushmishra206 |
#83 | test-mail-link-druapl9.png | 27.26 KB | amietpatial |
Comments
Comment #1
aalamaki CreditAttribution: aalamaki commentedThe following patch fixes the issue by checking for a domain suffix and converting only those that have it into a email link. Even this is not always foolproof but it fixes at least some issues.
Comment #2
aalamaki CreditAttribution: aalamaki commentedComment #3
aalamaki CreditAttribution: aalamaki commentedPlease ignore the previous patch; it will fail, did diff in wrong order. The following patch will work.
Comment #5
aalamaki CreditAttribution: aalamaki commentedTrying again...
Comment #6
aalamaki CreditAttribution: aalamaki commentedComment #8
aalamaki CreditAttribution: aalamaki commentedmmm what's wrong with the patch...works fine on my local, clean drupal installation
Comment #9
wroxbox CreditAttribution: wroxbox commentedHere is the filter patched and re-tested locally. Validated it is working as should. Lets see what the bot thinks.
Comment #11
afox CreditAttribution: afox commentedThe issue has a valid point, but as this goes against the standard, it should be a decision for the maintainer whether or not this should go in. I see few things to note here:
My suggestion:
Target only email addresses, requiring them to have a subdomain. This won't then affect URL's and is rarely used. I've attached a patch which sets a subdomain to be matched.
Comment #12
afox CreditAttribution: afox commentedComment #13
wroxbox CreditAttribution: wroxbox commentedIt seams working with the patch applied.
I would give +1 for this.
Comment #14
fullerja CreditAttribution: fullerja commentedPatch in 11 works for me
Comment #15
PavanL CreditAttribution: PavanL commentedComment #16
PavanL CreditAttribution: PavanL commentedComment #17
afox CreditAttribution: afox commented@PavanL thank you for your participation, but please don't modify the original post unless it's exceptionally unclear in what it's saying. Your changes were good and reasonable, but it isn't really good practice to rewrite somebody else's issue. Also, how in the world this was changed to 'needs work'...?
Comment #18
afox CreditAttribution: afox commentedComment #19
PavanL CreditAttribution: PavanL commentedComment #20
David_Rothstein CreditAttribution: David_Rothstein commentedLike #11, I'm not sure about this one (that comment contains a great summary of the pros and cons of such a change).
Either way, would need to go in Drupal 8 first, though.
Comment #21
tregismoreira CreditAttribution: tregismoreira commentedHere is my approach for D7 #2354401: URL filter converting invalid emails to mailto link
Comment #22
jelo CreditAttribution: jelo commentedPatch from #11 works for me in D7. I think afox makes a very logical suggestion to only target email patterns which will keep the bulk of the existing functionality as is. Any chance to get this committed?
Comment #23
afox CreditAttribution: afox commented@jelo you're right. We first need to get the D8 version working. So here's a D8-version with same changes (seemed to work nicely).
Comment #24
rteijeiro CreditAttribution: rteijeiro commentedGreat job @aFox!
BEFORE
AFTER
Comment #27
afox CreditAttribution: afox commentedTestbot apparently had a glitch. Now passed.
Comment #28
alexpottI think we should be adding to the files used in FilterUnitTest::testUrlFilterContent() to test this
Comment #29
Sutharsan CreditAttribution: Sutharsan commentedThis (failing) URL lead me to this issue:
https://www.google.be/maps/place/Rue+de+la+Victoire+39,+1060+Saint-Gilles/@50.831321,4.3468107,17z/data=!3m1!4b1!4m2!3m1!1s0x47c3c4668ae4d069:0xaf2df9dc39d8f03a?hl=fr
The patch fixes the filtering of this URL in Drupal 8. However a quick backport of #23 to Drupal 7 did not. So there have been more improvements to this function compared to D7. I propose to backport the whole
_filter_url()
code, not just the patch.Comment #30
larowlanHere's a failing test
Comment #32
jibranManually tested works fine even for the strings like
now@home.
@larowlan is this string worth adding to tests to check the edge case.Comment #33
larowlangreat idea jibran.
changed test line to
Comment #34
jibranRTBC++
Comment #35
Wim LeersSorry, two nits.
Hrm, not a subdomain, but rather a TLD? See https://en.wikipedia.org/wiki/Domain_name#Second-level_and_lower_level_d....
s/mailto -link/mailto-link/
or
s/mailto -link/mailto link/
Comment #36
alexpottLet's not change this here - it's out of scope and since this is testing filters potentially significant.
Comment #37
larowlanFixes #35 and #36
#36 was my editor settings, but agree, could be significant with filters.
Comment #38
jibranAll the feedback is addressed back to RTBC.
Comment #40
jibranSeems unrelated
Updates for Contrib module one Other LocaleUpdateTest.php 144 Drupal\locale\Tests\LocaleUpdateTest->testUpdateImportSourceRemote()
Comment #42
jibranBack to RTBC.
Comment #44
jibranFAILED: [[SimpleTest]]: [PHP 5.4 MySQL] 91,590 pass(es), 2,654 fail(s), and 1,057 exception(s).
this can't be true retesting.Comment #46
jibranBack to RTBC.
Comment #47
alexpottI think this is a good change. It is sensible to say that local domain names with no TLD are excluded because Drupal is about publishing content - but I think we need further tests.
jsmith@[192.168.2.1]
is a valid email address. See https://en.wikipedia.org/wiki/Email_address#Examples.Comment #48
jibranThanks for the suggestion @alexpott. We'll fix that as well. I think you wanted to add needs tests tag. We do have this issue in D7 as well that is why we want to back port it. Feel free to clarify yourself re-adding the tag for now.
Comment #49
richardbporter CreditAttribution: richardbporter as a volunteer commentedPatch in #11 failed to apply cleanly against Drupal 7.41. Re-rolled.
Comment #51
Screenack CreditAttribution: Screenack as a volunteer and at Duke University commentedI'm confirming that #49 works as expected against Drupal 7.43
Comment #54
nkraftSo patches for this issue were tested years ago, and I'm still struggling with this issue?
Maybe I can simplify the argument: nearly all of us know how to make a valid email link manually. Many content editors (ie, clients) do not. This filter is for those people.
Therefore, the filter should only convert email links if they satisfy the average standard email address. If someone has a weird email address WITHOUT a top level domain at the end (ex., jsmith@[192.168.2.1] ) -- those instances can be made into mailto links manually when the filter does not catch them. HOWEVER -- converting everything with an '@' sign in the middle of it to a mailto: link does not make sense. 'working@home' is never meant to be a valid email address; and you can not manually change this if the filter is turned on.
Can we please get this patch into D8 in the near future? This is the sort of stuff that is making me go crazy while working with D8.
Comment #55
nkraftAlternately -- if we could split out email conversion from regular URL conversion -- that would allow me to turn this faulty feature off. I'd settle for either option. Thanks, and I appreciate all the hours volunteers put into this. I was just very frustrated to research this issue only to find it had been discussed, patches made, and then it got effectively killed 2 years ago.
Comment #56
rakesh.gectcrLet me try to roll out against 8.4.x
Comment #57
rakesh.gectcrComment #58
rakesh.gectcrComment #61
jelo CreditAttribution: jelo commentedI agree with #54. It seems important to get this committed...
Comment #64
afinnarn CreditAttribution: afinnarn at University of Colorado Boulder commentedOn Drupal 7.57 I get "error: corrupt patch at line 17" when trying to apply the patch. I will attempt to re-roll...
Comment #65
afinnarn CreditAttribution: afinnarn at University of Colorado Boulder commentednevermind...I corrupted the patch myself.
Comment #67
isramv CreditAttribution: isramv commentedI can confirm that after 3 years, patch #49 works on Drupal 7...
Comment #68
Fabianx CreditAttribution: Fabianx as a volunteer and at Tag1 Consulting commentedI would be open to commit / fix this in Drupal 7, but it needs to be fixed in Drupal 8 first.
Comment #70
darkodev CreditAttribution: darkodev commented#49 applies cleanly to 7.65
Comment #71
richardbporter CreditAttribution: richardbporter as a volunteer commentedLooks like the + symbol got removed from the URL pattern regex which I think is why the tests were failing. I added that back and fixed a typo in the comments.
A new test for this functionality would be nice but I'm having trouble debugging that kernel test at the moment.
Comment #72
richardbporter CreditAttribution: richardbporter as a volunteer commentedRe-rolled the D7 patch in 49 with the same changes.
Comment #73
richardbporter CreditAttribution: richardbporter as a volunteer commentedComment #74
richardbporter CreditAttribution: richardbporter as a volunteer commentedComment #75
richardbporter CreditAttribution: richardbporter as a volunteer commentedMade some adjustments based on #35and #28.
Comment #76
richardbporter CreditAttribution: richardbporter as a volunteer commentedRe-rolled again for D7 with the same changes.
Also, it appears I overlooked the work already done in #37. Apologies.
Comment #77
richardbporter CreditAttribution: richardbporter as a volunteer commentedComment #79
darkodev CreditAttribution: darkodev commentedPatch at #76 working here (with the plus sign).
Where are we with the D8 blocker for the D7 working patch to make it into a release?
Any chance for 7.68?
Thanks for everyone's work on this.
Comment #81
tanubansal CreditAttribution: tanubansal at Salsa Digital commentedAfter enabling 'Convert URLs into links' for Basic HTML on 9.1, I have created a basic page and added both the links.
Its showing text as a link if there is no domain suffix.
Can we have a patch fix for 9.1?
Comment #82
Kasey_MK CreditAttribution: Kasey_MK commentedd8-require-tld-for-mailto-links-2016739-73.patch in #75 works for us, thank you!
Comment #83
amietpatial CreditAttribution: amietpatial as a volunteer and at gai Technologies Pvt Ltd for gai Technologies Pvt Ltd commented#75 works for me too, thank you!
Attached is the screenshot:
Comment #84
quietone CreditAttribution: quietone as a volunteer commentedNoticed that this is tagged 'Needs tests' but it also RTBC, it can't be both. I looked at the patch and indeed there are no tests. The latest patch is for 8.8.x. It needs to be against 9.1.x.
Setting NW for tests and to have a patch for 9.1.x.
Comment #85
ayushmishra206 CreditAttribution: ayushmishra206 at OpenSense Labs commentedComment #86
ayushmishra206 CreditAttribution: ayushmishra206 at OpenSense Labs commentedRerolled for 9.1. Please review
Comment #87
ayushmishra206 CreditAttribution: ayushmishra206 at OpenSense Labs commentedSetting back to NW for tests.
Comment #88
alexpottThis change is a regression. #1657886: Filter "Convert URLs into links" doesn't support multilingual web addresses changed this to allow multilingual characters. See https://en.wikipedia.org/wiki/International_email
Comment #91
NikolaAt CreditAttribution: NikolaAt commentedAdded a patch that keeps the current format of the domain pattern (multilingual support) and make a change of the regex, so if no dot is added after the @, text will not be transformed to mailto link
Comment #92
mohit_aghera CreditAttribution: mohit_aghera at QED42 commentedIssue history has many patches in the past where test cases have been added.
I've clubbed together test cases and created a patch.
Test cases are passing on local.
Comment #93
mark_fullmerThe patch in #92 works as designed, and tests pass, and still cleanly applies to the 9.3.x-dev branch. Marking this as RTBC, accordingly, with the desire that this is next reviewed by the core maintainers.
Comment #94
justcaldwell+1 for the RTBC (and hopefully getting it reviewed/committed). We've been using this for months now with no issue.
Comment #95
alexpottThe change to the regex looks good in my opinion. I might assign both $domain and $email_domain at the same point in the code so if you change one you'll consider the other.
These changes might be automatically occurring due to IDE settings but we should not be making them here. It's out-of-scope and I'm not sure they are correct.
Comment #96
alexpottAlso not sure about this text. Firstly the use of the acronym without it being defined earlier and also the comma is incorrect.
Comment #97
mark_fullmerThanks for the review, alexpott!
The attached patch addresses comments in 95 & 96:
1. The definition of the email domain is now adjacent to the generic domain pattern.
2. The comment text clarifies how the email domain differs.
3. The newlines errroneously added to .txt files in 92 are excised.
Comment #98
Jeff Cardwell CreditAttribution: Jeff Cardwell at University of Texas at Austin commentedComments from #95 and #96 seem to be addressed. Setting back to RTBC.
Comment #99
alexpottCommitted 8ff4d48 and pushed to 9.3.x. Thanks!
Committed f7ccf32 and pushed to 9.2.x. Thanks!
Backported to 9.2.x because this is a bug and the implementation only affects mailto links so the scope is small. The use something@something to mean things like ladygaga@oscars feels way more commonplace than it was when this issue was opened.
In order for this issue to be backported to Drupal 7 the current policy is to open a new issue.
Comment #101
alexpottComment #104
douggreen CreditAttribution: douggreen commented@Fabianx now that this is in D9, can we back port to D7 please. There's a long history here. While the patch in #49 works, attached is a new D7 re-roll with all the changes that made it into D9.
Comment #105
darkodev CreditAttribution: darkodev commented#104 @douggreen, as per, "In order for this issue to be backported to Drupal 7 the current policy is to open a new issue" in #99 and because you have a proposed patch, can you open a new issue to backport and reference this as related issue. Cheers.