Fix parsing for description links with parentheses

With markdown plugin disabled

relates to #966
This commit is contained in:
ArthurHoaro 2017-09-29 18:52:38 +02:00
parent 0cba184cf8
commit 601faf9751
2 changed files with 11 additions and 1 deletions

View file

@ -109,7 +109,7 @@ function count_private($links)
*/ */
function text2clickable($text, $redirector = '') 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)) { if (empty($redirector)) {
return preg_replace($regex, '<a href="$1">$1</a>', $text); return preg_replace($regex, '<a href="$1">$1</a>', $text);

View file

@ -103,6 +103,16 @@ public function testText2clickableWithoutRedirector()
$expectedText = 'stuff <a href="http://hello.there/is=someone#here">http://hello.there/is=someone#here</a> otherstuff'; $expectedText = 'stuff <a href="http://hello.there/is=someone#here">http://hello.there/is=someone#here</a> otherstuff';
$processedText = text2clickable($text, ''); $processedText = text2clickable($text, '');
$this->assertEquals($expectedText, $processedText); $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);
} }
/** /**