Defect #8395
closedTags start with 'pre' are handled as 'pre' tag in Textile
0%
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
Related issues
Updated by Etienne Massip over 13 years ago
- Category changed from Wiki to Text formatting
- Target version set to Candidate for next minor release
Updated by Go MAEDA over 6 years ago
- File pre-parse-bug@2x.png pre-parse-bug@2x.png added
- Subject changed from Parsing of pre tag in wiki is buggy to Tags start with 'pre' are handled as 'pre' tag in Textile
- Description updated (diff)
This old bug is still alive in Redmine 4.0 under development.
"preeeee" in the following text is misrecognized as "pre".
<preeeee> aaaaaaa </preeeee>
Updated by Takenori TAKAKI about 6 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
Updated by Go MAEDA about 6 years ago
- File 8395-note4.png 8395-note4.png added
- Status changed from New to Needs feedback
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?
Updated by Takenori TAKAKI about 6 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?
Updated by Go MAEDA about 6 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.
Updated by Marius BĂLTEANU about 6 years ago
- File test_for_8395.patch test_for_8395.patch added
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}" : "<#{$1}#{'>' unless $3.blank?}" }
end
end
Updated by Marius BĂLTEANU about 6 years ago
- Related to deleted (Defect #7309: '<pre/>' tag)
Updated by Marius BĂLTEANU about 6 years ago
- Has duplicate Defect #7309: '<pre/>' tag added
Updated by Go MAEDA about 6 years ago
- Status changed from New to Resolved
- Assignee set to Go MAEDA
- Resolution set to Fixed
Updated by Go MAEDA about 6 years ago
- Status changed from Resolved to Closed
Committed #8395#note-9. Thank you all for the contribution.