]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Fix parsing for description links with parentheses 976/head
authorArthurHoaro <arthur@hoa.ro>
Fri, 29 Sep 2017 16:52:38 +0000 (18:52 +0200)
committerArthurHoaro <arthur@hoa.ro>
Fri, 29 Sep 2017 16:52:38 +0000 (18:52 +0200)
With markdown plugin disabled

relates to #966

application/LinkUtils.php
tests/LinkUtilsTest.php

index 976474de721ad14636b9b431f0cec06a8920e120..267e62cde41f9193e384cede8665311fe76ccd6e 100644 (file)
@@ -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, '<a href="$1">$1</a>', $text);
index 7c0d4b0bdc9bf7e0c029231bab2d07e16db26082..c77922ecea0c2a13dcbd8ff59e961925775956cb 100644 (file)
@@ -103,6 +103,16 @@ class LinkUtilsTest extends PHPUnit_Framework_TestCase
         $expectedText = 'stuff <a href="http://hello.there/is=someone#here">http://hello.there/is=someone#here</a> otherstuff';
         $processedText = text2clickable($text, '');
         $this->assertEquals($expectedText, $processedText);
+
+        $text = 'stuff http://hello.there/is=someone#here(please) otherstuff';
+        $expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)">http://hello.there/is=someone#here(please)</a> otherstuff';
+        $processedText = text2clickable($text, '');
+        $this->assertEquals($expectedText, $processedText);
+
+        $text = 'stuff http://hello.there/is=someone#here(please)&no otherstuff';
+        $expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)&no">http://hello.there/is=someone#here(please)&no</a> otherstuff';
+        $processedText = text2clickable($text, '');
+        $this->assertEquals($expectedText, $processedText);
     }
 
     /**