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:
Philipp 2019-03-13 07:05:52 +01:00 committed by GitHub
commit c8331eb068
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 14 deletions

View file

@ -361,7 +361,7 @@ class Strings
( # Capture 1: entire matched URL
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:
[^\s()<>]+ # Run of non-space, non-()<>

View file

@ -86,6 +86,22 @@ class BBCodeTest extends MockedTest
'data' => 'http://example/path',
'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)
{
$output = BBCode::convert($data);
if ($assertHTML) {
$assert = '<a href="' . $data . '" target="_blank">' . $data . '</a>';
} else {
$assert = $data;
}
if ($assertHTML) {
$this->assertEquals($assert, $output);
} else {
$this->assertNotEquals($assert, $output);
}
}
}