Merge pull request #6857 from friendica/MrPetovan-patch-autolinker-domain
Remove new lines from domain name part of autolinker regular expression in Util\Strings
This commit is contained in:
commit
c8331eb068
|
@ -358,17 +358,17 @@ class Strings
|
||||||
return '@(?xi)
|
return '@(?xi)
|
||||||
(?<![=\'\]"/]) # Not preceded by [, =, \', ], ", /
|
(?<![=\'\]"/]) # Not preceded by [, =, \', ], ", /
|
||||||
\b
|
\b
|
||||||
( # Capture 1: entire matched URL
|
( # Capture 1: entire matched URL
|
||||||
https?:// # http or https protocol
|
https?:// # http or https protocol
|
||||||
(?:
|
(?:
|
||||||
[^/.][^/]+[.][^/]+/? # looks like domain name followed by a slash
|
[^/\s.][^/\s]+[.][^\s/]+/? # looks like domain name followed by a slash
|
||||||
)
|
)
|
||||||
(?: # One or more:
|
(?: # One or more:
|
||||||
[^\s()<>]+ # Run of non-space, non-()<>
|
[^\s()<>]+ # Run of non-space, non-()<>
|
||||||
| # or
|
| # or
|
||||||
\(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
|
\(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
|
||||||
| # or
|
| # or
|
||||||
[^\s`!()\[\]{};:\'".,<>?«»“”‘’] # not a space or one of these punct chars
|
[^\s`!()\[\]{};:\'".,<>?«»“”‘’] # not a space or one of these punct chars
|
||||||
)*
|
)*
|
||||||
)@';
|
)@';
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,22 @@ class BBCodeTest extends MockedTest
|
||||||
'data' => 'http://example/path',
|
'data' => 'http://example/path',
|
||||||
'assertHTML' => false
|
'assertHTML' => false
|
||||||
],
|
],
|
||||||
|
'bug-6857-domain-start' => [
|
||||||
|
'data' => "http://\nexample.com",
|
||||||
|
'assertHTML' => false
|
||||||
|
],
|
||||||
|
'bug-6857-domain-end' => [
|
||||||
|
'data' => "http://example\n.com",
|
||||||
|
'assertHTML' => false
|
||||||
|
],
|
||||||
|
'bug-6857-tld' => [
|
||||||
|
'data' => "http://example.\ncom",
|
||||||
|
'assertHTML' => false
|
||||||
|
],
|
||||||
|
'bug-6857-end' => [
|
||||||
|
'data' => "http://example.com\ntest",
|
||||||
|
'assertHTML' => false
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,12 +116,11 @@ class BBCodeTest extends MockedTest
|
||||||
public function testAutoLinking($data, $assertHTML)
|
public function testAutoLinking($data, $assertHTML)
|
||||||
{
|
{
|
||||||
$output = BBCode::convert($data);
|
$output = BBCode::convert($data);
|
||||||
|
$assert = '<a href="' . $data . '" target="_blank">' . $data . '</a>';
|
||||||
if ($assertHTML) {
|
if ($assertHTML) {
|
||||||
$assert = '<a href="' . $data . '" target="_blank">' . $data . '</a>';
|
$this->assertEquals($assert, $output);
|
||||||
} else {
|
} else {
|
||||||
$assert = $data;
|
$this->assertNotEquals($assert, $output);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertEquals($assert, $output);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue