From: ArthurHoaro Date: Sat, 30 Sep 2017 12:25:53 +0000 (+0200) Subject: Merge pull request #976 from ArthurHoaro/hotfix/url-parentheses X-Git-Tag: v0.9.2~1^2~6 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=3512f4461722c9a3c7cf6511232bda156bf91970;hp=7c670b39a2505f625066e7d87e1536fc02e9d6fc;p=github%2Fshaarli%2FShaarli.git Merge pull request #976 from ArthurHoaro/hotfix/url-parentheses Fix parsing for description links with parentheses --- diff --git a/application/LinkUtils.php b/application/LinkUtils.php index 976474de..267e62cd 100644 --- a/application/LinkUtils.php +++ b/application/LinkUtils.php @@ -109,7 +109,7 @@ function count_private($links) */ function text2clickable($text, $redirector = '') { - $regex = '!(((?:https?|ftp|file)://|apt:|magnet:)\S+[[:alnum:]]/?)!si'; + $regex = '!(((?:https?|ftp|file)://|apt:|magnet:)\S+[a-z0-9\(\)]/?)!si'; if (empty($redirector)) { return preg_replace($regex, '$1', $text); diff --git a/tests/LinkUtilsTest.php b/tests/LinkUtilsTest.php index 7c0d4b0b..c77922ec 100644 --- a/tests/LinkUtilsTest.php +++ b/tests/LinkUtilsTest.php @@ -103,6 +103,16 @@ class LinkUtilsTest extends PHPUnit_Framework_TestCase $expectedText = 'stuff http://hello.there/is=someone#here otherstuff'; $processedText = text2clickable($text, ''); $this->assertEquals($expectedText, $processedText); + + $text = 'stuff http://hello.there/is=someone#here(please) otherstuff'; + $expectedText = 'stuff http://hello.there/is=someone#here(please) otherstuff'; + $processedText = text2clickable($text, ''); + $this->assertEquals($expectedText, $processedText); + + $text = 'stuff http://hello.there/is=someone#here(please)&no otherstuff'; + $expectedText = 'stuff http://hello.there/is=someone#here(please)&no otherstuff'; + $processedText = text2clickable($text, ''); + $this->assertEquals($expectedText, $processedText); } /**