Issue #3372666 by hadsie, poker10, ayushmishra206, jibran, larowlan, amietpatial, alexpott, aalamaki, afox, mark_fullmer, mohit_aghera, Wim Leers, wroxbox, tanubansal, rteijeiro, NikolaAt, rakesh.gectcr, richardbporter: D7 Backport: Links with "@" are converted into email addresses even if there is no domain suffix present

merge-requests/5460/head
mcdruid 2023-11-10 11:50:01 +00:00
parent 1acc41ae01
commit 5ea9bbef7c
No known key found for this signature in database
3 changed files with 10 additions and 3 deletions

View File

@ -1480,9 +1480,12 @@ function _filter_url($text, $filter) {
// Prepare domain name pattern.
// The ICANN seems to be on track towards accepting more diverse top level
// domains, so this pattern has been "future-proofed" to allow for TLDs
// of length 2-64.
// domains (TLDs), so this pattern has been "future-proofed" to allow for
// TLDs of length 2-64.
$domain = '(?:[A-Za-z0-9._+-]+\.)?[A-Za-z]{2,64}\b';
// Mail domains differ from the generic domain pattern, specifically:
// A . character must be present in the string that follows the @ character.
$email_domain = '(?:[\p{L}\p{M}\p{N}._+-]+\.)+[\p{L}\p{M}]{2,64}\b';
$ip = '(?:[0-9]{1,3}\.){3}[0-9]{1,3}';
$auth = '[a-zA-Z0-9:%_+*~#?&=.,/;-]+@';
$trail = '[a-zA-Z0-9:%_+*~#&\[\]=/;?!\.,-]*[a-zA-Z0-9:%_+*~#&\[\]=/;-]';
@ -1499,7 +1502,7 @@ function _filter_url($text, $filter) {
$tasks['_filter_url_parse_full_links'] = $pattern;
// Match e-mail addresses.
$url_pattern = "[A-Za-z0-9._+-]{1,254}@(?:$domain)";
$url_pattern = "[\p{L}\p{M}\p{N}._+-]{1,254}@(?:$email_domain)";
$pattern = "`($url_pattern)`";
$tasks['_filter_url_parse_email_links'] = $pattern;

View File

@ -9,6 +9,7 @@ This is just a www.test.com. paragraph with person@test.com. some http://www.tes
http://www.test.com
www.test.com
person@test.com
person@test
<code>www.test.com</code>
What about tags that don't exist <x>like x say www.test.com</x>? And what about tag <pooh>beginning www.test.com with p?</pooh>
@ -25,6 +26,7 @@ The old URL filter has problems with <a title="kind of link www.example.com with
<dt>www.test.com</dt>
<dd>http://www.test.com</dd>
<dd>person@test.com</dd>
<dd>person@test</dd>
<dt>check www.test.com</dt>
<dd>this with some text around: http://www.test.com not so easy person@test.com now?</dd>
</dl>

View File

@ -9,6 +9,7 @@ This is just a <a href="http://www.test.com">www.test.com</a>. paragraph with <a
<a href="http://www.test.com">http://www.test.com</a>
<a href="http://www.test.com">www.test.com</a>
<a href="mailto:person@test.com">person@test.com</a>
person@test
<code>www.test.com</code>
What about tags that don't exist <x>like x say <a href="http://www.test.com">www.test.com</a></x>? And what about tag <pooh>beginning <a href="http://www.test.com">www.test.com</a> with p?</pooh>
@ -25,6 +26,7 @@ The old URL filter has problems with <a title="kind of link www.example.com with
<dt><a href="http://www.test.com">www.test.com</a></dt>
<dd><a href="http://www.test.com">http://www.test.com</a></dd>
<dd><a href="mailto:person@test.com">person@test.com</a></dd>
<dd>person@test</dd>
<dt>check <a href="http://www.test.com">www.test.com</a></dt>
<dd>this with some text around: <a href="http://www.test.com">http://www.test.com</a> not so easy <a href="mailto:person@test.com">person@test.com</a> now?</dd>
</dl>