Unverified Commit 8ff4d48c authored by alexpott's avatar alexpott
Browse files

Issue #2016739 by richardbporter, larowlan, aalamaki, afox, wroxbox,...

Issue #2016739 by richardbporter, larowlan, aalamaki, afox, wroxbox, mark_fullmer, mohit_aghera, ayushmishra206, rakesh.gectcr, NikolaAt, rteijeiro, tanubansal, amietpatial, jibran, alexpott, Wim Leers: Links with "@" are converted into email addresses even if there is no domain suffix present
parent 61bff4ef
...@@ -490,9 +490,12 @@ function _filter_url($text, $filter) { ...@@ -490,9 +490,12 @@ function _filter_url($text, $filter) {
// Prepare domain name pattern. // Prepare domain name pattern.
// The ICANN seems to be on track towards accepting more diverse top level // 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 // domains (TLDs), so this pattern has been "future-proofed" to allow for
// of length 2-64. // TLDs of length 2-64.
$domain = '(?:[\p{L}\p{M}\p{N}._+-]+\.)?[\p{L}\p{M}]{2,64}\b'; $domain = '(?:[\p{L}\p{M}\p{N}._+-]+\.)?[\p{L}\p{M}]{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}'; $ip = '(?:[0-9]{1,3}\.){3}[0-9]{1,3}';
$auth = '[\p{L}\p{M}\p{N}:%_+*~#?&=.,/;-]+@'; $auth = '[\p{L}\p{M}\p{N}:%_+*~#?&=.,/;-]+@';
$trail = '(' . $valid_url_path . '*)?(\\?' . $valid_url_query_chars . '*' . $valid_url_query_ending_chars . ')?'; $trail = '(' . $valid_url_path . '*)?(\\?' . $valid_url_query_chars . '*' . $valid_url_query_ending_chars . ')?';
...@@ -503,7 +506,7 @@ function _filter_url($text, $filter) { ...@@ -503,7 +506,7 @@ function _filter_url($text, $filter) {
$tasks['_filter_url_parse_full_links'] = $pattern; $tasks['_filter_url_parse_full_links'] = $pattern;
// Match email addresses. // Match email addresses.
$url_pattern = "[\p{L}\p{M}\p{N}._+-]{1,254}@(?:$domain)"; $url_pattern = "[\p{L}\p{M}\p{N}._+-]{1,254}@(?:$email_domain)";
$pattern = "`($url_pattern)`u"; $pattern = "`($url_pattern)`u";
$tasks['_filter_url_parse_email_links'] = $pattern; $tasks['_filter_url_parse_email_links'] = $pattern;
......
...@@ -9,6 +9,7 @@ This is just a www.test.com. paragraph with person@test.com. some http://www.tes ...@@ -9,6 +9,7 @@ This is just a www.test.com. paragraph with person@test.com. some http://www.tes
http://www.test.com http://www.test.com
www.test.com www.test.com
person@test.com person@test.com
person@test
<code>www.test.com</code> <code>www.test.com</code>
http://test.com/?search=test http://test.com/?search=test
http://test.com/?search=Test http://test.com/?search=Test
...@@ -28,6 +29,7 @@ The old URL filter has problems with <a title="kind of link www.example.com with ...@@ -28,6 +29,7 @@ The old URL filter has problems with <a title="kind of link www.example.com with
<dt>www.test.com</dt> <dt>www.test.com</dt>
<dd>http://www.test.com</dd> <dd>http://www.test.com</dd>
<dd>person@test.com</dd> <dd>person@test.com</dd>
<dd>person@test</dd>
<dt>check www.test.com</dt> <dt>check www.test.com</dt>
<dd>this with some text around: http://www.test.com not so easy person@test.com now?</dd> <dd>this with some text around: http://www.test.com not so easy person@test.com now?</dd>
</dl> </dl>
......
...@@ -9,6 +9,7 @@ This is just a <a href="http://www.test.com">www.test.com</a>. paragraph with <a ...@@ -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">http://www.test.com</a>
<a href="http://www.test.com">www.test.com</a> <a href="http://www.test.com">www.test.com</a>
<a href="mailto:person@test.com">person@test.com</a> <a href="mailto:person@test.com">person@test.com</a>
person@test
<code>www.test.com</code> <code>www.test.com</code>
<a href="http://test.com/?search=test">http://test.com/?search=test</a> <a href="http://test.com/?search=test">http://test.com/?search=test</a>
<a href="http://test.com/?search=Test">http://test.com/?search=Test</a> <a href="http://test.com/?search=Test">http://test.com/?search=Test</a>
...@@ -28,6 +29,7 @@ The old URL filter has problems with <a title="kind of link www.example.com with ...@@ -28,6 +29,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> <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="http://www.test.com">http://www.test.com</a></dd>
<dd><a href="mailto:person@test.com">person@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> <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> <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> </dl>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment