Defect #30371

Textile formatter generates broken link if a URL is followed by a tag

Added by Go MAEDA 11 months ago. Updated 11 months ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Text formatting
Target version:Candidate for next minor release
Resolution: Affected version:

Description

[Input]

http://www.example.com/<foo>

[Expected output]

<a class="external" href="http://www.example.com/">http://www.example.com/</a>&lt;foo&gt;

[Actual output]

<a class="external" href="http://www.example.com/&amp;lt;foo">http://www.example.com/&amp;lt;foo</a>

broken-link@2x.png (10.8 KB) Go MAEDA, 2019-01-10 10:50

0001-Remove-unnecessary-trailing-white-spaces.patch Magnifier (23.6 KB) Yuichi HARADA, 2019-01-23 07:23

0002-URL-followed-by-tag.patch Magnifier (3.14 KB) Yuichi HARADA, 2019-01-23 07:23

History

#1 Updated by Yuichi HARADA 11 months ago

I improved the regular expression to exclude subsequent characters on "&lt;" from a URL.
I attached patches.

diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb
index 66764551d..8bd8f64bc 100644
--- a/lib/redmine/wiki_formatting.rb
+++ b/lib/redmine/wiki_formatting.rb
@@ -126,7 +126,7 @@ module Redmine
                         (\/)?                    # slash
                       )
                       ((?:&gt;)?|[^[:alnum:]_\=\/;\(\)]*?)               # post
-                      (?=<|\s|$)
+                      (?=&lt;|<|\s|$)
                      }x unless const_defined?(:AUTO_LINK_RE)

       # Destructively replaces urls into clickable links
diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb
index 9107da611..ff0621b9f 100644
--- a/lib/redmine/wiki_formatting/textile/redcloth3.rb
+++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb
@@ -830,7 +830,7 @@ class RedCloth3 < String
             (\/)?                      # $slash
             ([^[:alnum:]_\=\/;\(\)]*?)         # $post
             )
-            (?=<|\s|$)
+            (?=&lt;|<|\s|$)
         /x
 #" 
     def inline_textile_link( text )

#2 Updated by Go MAEDA 11 months ago

  • Target version set to Candidate for next minor release

Also available in: Atom PDF