diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 3edc9ba906..681edb1c87 100644 --- a/src/Util/Strings.php +++ b/src/Util/Strings.php @@ -358,17 +358,17 @@ class Strings return '@(?xi) (?]+ # Run of non-space, non-()<> - | # or - \(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels - | # or - [^\s`!()\[\]{};:\'".,<>?«»“”‘’] # not a space or one of these punct chars + (?: # One or more: + [^\s()<>]+ # Run of non-space, non-()<> + | # or + \(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels + | # or + [^\s`!()\[\]{};:\'".,<>?«»“”‘’] # not a space or one of these punct chars )* )@'; } diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php index f155eeee3d..2f9a244ccc 100644 --- a/tests/src/Content/Text/BBCodeTest.php +++ b/tests/src/Content/Text/BBCodeTest.php @@ -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); + $assert = '' . $data . ''; if ($assertHTML) { - $assert = '' . $data . ''; + $this->assertEquals($assert, $output); } else { - $assert = $data; + $this->assertNotEquals($assert, $output); } - - $this->assertEquals($assert, $output); } -} \ No newline at end of file +}