From 8f96e383a7a72de5619520672092cd6a110442d4 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 11 Mar 2019 14:37:56 -0400 Subject: [PATCH 1/3] Remove new lines from domain name part of autolinker regular expression in Util\Strings - Fixes issue where the autolinker would include the next paragraph is a pathless URL was followed by new lines. --- src/Util/Strings.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 )* )@'; } From fedf29e02320b4791ca6f15a2c6bb41e5712c415 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 11 Mar 2019 15:27:22 -0400 Subject: [PATCH 2/3] Add tests for bug #6857 --- tests/src/Content/Text/BBCodeTest.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php index f155eeee3d..fe37b91cd1 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 + ], ]; } @@ -108,4 +124,4 @@ class BBCodeTest extends MockedTest $this->assertEquals($assert, $output); } -} \ No newline at end of file +} From c5073e2036d84e4394257dfbdd1cc48510b24aa0 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 13 Mar 2019 00:40:54 -0400 Subject: [PATCH 3/3] Prevent side effects with BBCode::convert in testAutoLinking() --- tests/src/Content/Text/BBCodeTest.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php index fe37b91cd1..2f9a244ccc 100644 --- a/tests/src/Content/Text/BBCodeTest.php +++ b/tests/src/Content/Text/BBCodeTest.php @@ -116,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); } }