]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Markdown plugin: fix RSS feed direct link reverse 1355/head
authorArthurHoaro <arthur@hoa.ro>
Thu, 15 Aug 2019 10:56:32 +0000 (12:56 +0200)
committerArthurHoaro <arthur@hoa.ro>
Thu, 15 Aug 2019 10:56:32 +0000 (12:56 +0200)
The plugin was only reversing permalinks and failed with setting rss_permalinks set to false

plugins/markdown/markdown.php
tests/plugins/PluginMarkdownTest.php

index 628970d626ff4064b0daecc0b97fd40c855d3551..f6f66cc561fc0c697e06c1b2776c5d09510b299b 100644 (file)
@@ -259,7 +259,7 @@ function reverse_space2nbsp($description)
 
 function reverse_feed_permalink($description)
 {
-    return preg_replace('@&#8212; <a href="([^"]+)" title="[^"]+">(\w+)</a>$@im', '&#8212; [$2]($1)', $description);
+    return preg_replace('@&#8212; <a href="([^"]+)" title="[^"]+">([^<]+)</a>$@im', '&#8212; [$2]($1)', $description);
 }
 
 /**
index 9ddbc558f3d50294fe286322877d099c30ce0b4a..15fa9ba598672d27f46ec989c7c4fd63ccf1c8a7 100644 (file)
@@ -156,6 +156,16 @@ class PluginMarkdownTest extends \PHPUnit\Framework\TestCase
         $this->assertEquals($expected, $processedText);
     }
 
+    public function testReverseFeedDirectLink()
+    {
+        $text = 'Description... ';
+        $text .= '&#8212; <a href="http://domain.tld/?0oc_VQ" title="Direct link">Direct link</a>';
+        $expected = 'Description... &#8212; [Direct link](http://domain.tld/?0oc_VQ)';
+        $processedText = reverse_feed_permalink($text);
+
+        $this->assertEquals($expected, $processedText);
+    }
+
     public function testReverseLastFeedPermalink()
     {
         $text = 'Description... ';