Project

General

Profile

Actions

Defect #8395

closed

Tags start with 'pre' are handled as 'pre' tag in Textile

Added by Joe Kandaba about 13 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Text formatting
Target version:
Start date:
2011-05-18
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

If you use < and > in your wiki you might have something like:

<previous> <next> etc...

As you can see above the < previous > is handled as < pre > which i think should not be the case and is a bug in the parser.


Files

pre-parse-bug@2x.png (6.05 KB) pre-parse-bug@2x.png Go MAEDA, 2018-10-06 01:48
8395-note4.png (7.79 KB) 8395-note4.png Go MAEDA, 2018-11-19 01:04
8395-note4.png (7.79 KB) 8395-note4.png Go MAEDA, 2018-11-19 01:06
test_for_8395.patch (818 Bytes) test_for_8395.patch Marius BĂLTEANU, 2018-11-26 00:42

Related issues

Related to Redmine - Defect #7375: <pre> ... </pre> doesn't escape wiki syntax correctlyClosed2011-01-19

Actions
Has duplicate Redmine - Defect #7309: '<pre/>' tagClosed2011-01-12

Actions
Actions #1

Updated by Etienne Massip about 13 years ago

  • Category changed from Wiki to Text formatting
  • Target version set to Candidate for next minor release
Actions #2

Updated by Go MAEDA over 5 years ago

This old bug is still alive in Redmine 4.0 under development.

"preeeee" in the following text is misrecognized as "pre".

<preeeee>
aaaaaaa
</preeeee>

Actions #3

Updated by Go MAEDA over 5 years ago

  • Description updated (diff)
Actions #4

Updated by Takenori TAKAKI over 5 years ago

To fix this probrem, It would be necessary to add a harf-space character
between the pattern of tag name and pattern of the attributes in the regxp defined on RedCloth3::OFFTAG_MATCH.

As below.

diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb
index 6ffd7c78c..074017a35 100644
--- a/lib/redmine/wiki_formatting/textile/redcloth3.rb
+++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb
@@ -1049,7 +1049,7 @@ class RedCloth3 < String
     end

     OFFTAGS = /(code|pre|kbd|notextile)/
-    OFFTAG_MATCH = /(?:(<\/#{ OFFTAGS }>)|(<#{ OFFTAGS }[^>]*>))(.*?)(?=<\/?#{ OFFTAGS }\W|\Z)/mi
+    OFFTAG_MATCH = /(?:(<\/#{ OFFTAGS }>)|(<#{ OFFTAGS } [^>]*>))(.*?)(?=<\/?#{ OFFTAGS }\W|\Z)/mi
     OFFTAG_OPEN = /<#{ OFFTAGS }/
     OFFTAG_CLOSE = /<\/?#{ OFFTAGS }/
     HASTAG_MATCH = /(<\/?\w[^\n]*?>)/m

Actions #5

Updated by Go MAEDA over 5 years ago

Takenori TAKAKI wrote:

To fix this probrem, It would be necessary to add a harf-space character
between the pattern of tag name and pattern of the attributes in the regxp defined on RedCloth3::OFFTAG_MATCH.

As below.
[...]

After applying the patch #8395#note-4, an unnecessary blank line is inserted before the first line inside pre. Could you check the patch?

Actions #6

Updated by Go MAEDA over 5 years ago

Actions #7

Updated by Takenori TAKAKI over 5 years ago

Go MAEDA wrote:

After applying the patch #8395#note-4, an unnecessary blank line is inserted before the first line inside pre. Could you check the patch?

Thank you for pointing out my patch's bug (#8395#note-6). I confirmed same trouble on my environment too...
To fix the bug, Necessary to change RedCloth3::OFFTAG_MATCH as below.

diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb
index 6ffd7c78c..6894d4ee6 100644
--- a/lib/redmine/wiki_formatting/textile/redcloth3.rb
+++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb
@@ -1049,7 +1049,7 @@ class RedCloth3 < String
     end

     OFFTAGS = /(code|pre|kbd|notextile)/
-    OFFTAG_MATCH = /(?:(<\/#{ OFFTAGS }>)|(<#{ OFFTAGS }[^>]*>))(.*?)(?=<\/?#{ OFFTAGS }\W|\Z)/mi
+    OFFTAG_MATCH = /(?:(<\/#{ OFFTAGS }>)|(<#{ OFFTAGS }(?:>| [^>]*>)))(.*?)(?=<\/?#{ OFFTAGS }\W|\Z)/mi
     OFFTAG_OPEN = /<#{ OFFTAGS }/
     OFFTAG_CLOSE = /<\/?#{ OFFTAGS }/
     HASTAG_MATCH = /(<\/?\w[^\n]*?>)/m

Could you please try the new patch again?

Actions #8

Updated by Go MAEDA over 5 years ago

  • Status changed from Needs feedback to New
  • Target version changed from Candidate for next minor release to 3.4.7

LGTM. The patch can be applied to the trunk and 3.4-stable cleanly. Setting target version to 3.4.7.

Actions #9

Updated by Marius BĂLTEANU over 5 years ago

Attached a test case for this issue.

Another way to fix this is to add to the regex the word boundary (\b):

diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb
index 6ffd7c7..56085ad 100644
--- a/lib/redmine/wiki_formatting/textile/redcloth3.rb
+++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb
@@ -1049,7 +1049,7 @@ class RedCloth3 < String
     end

     OFFTAGS = /(code|pre|kbd|notextile)/
-    OFFTAG_MATCH = /(?:(<\/#{ OFFTAGS }>)|(<#{ OFFTAGS }[^>]*>))(.*?)(?=<\/?#{ OFFTAGS }\W|\Z)/mi
+    OFFTAG_MATCH = /(?:(<\/#{ OFFTAGS }\b>)|(<#{ OFFTAGS }\b[^>]*>))(.*?)(?=<\/?#{ OFFTAGS }\b\W|\Z)/mi
     OFFTAG_OPEN = /<#{ OFFTAGS }/
     OFFTAG_CLOSE = /<\/?#{ OFFTAGS }/
     HASTAG_MATCH = /(<\/?\w[^\n]*?>)/m
@@ -1216,4 +1216,3 @@ class RedCloth3 < String
       text.gsub!(%r{<(\/?([!\w]+)[^<>\n]*)(>?)}) {|m| ALLOWED_TAGS.include?($2) ? "<#{$1}#{$3}" : "&lt;#{$1}#{'&gt;' unless $3.blank?}" }
     end
 end

Actions #10

Updated by Marius BĂLTEANU over 5 years ago

Actions #11

Updated by Marius BĂLTEANU over 5 years ago

Actions #12

Updated by Go MAEDA over 5 years ago

  • Status changed from New to Resolved
  • Assignee set to Go MAEDA
  • Resolution set to Fixed
Actions #13

Updated by Go MAEDA over 5 years ago

  • Status changed from Resolved to Closed

Committed #8395#note-9. Thank you all for the contribution.

Actions

Also available in: Atom PDF