Vote #69936
完了Tags start with 'pre' are handled as 'pre' tag in Textile
0%
説明
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.
journals
--------------------------------------------------------------------------------
This old bug is still alive in Redmine 4.0 under development.
"preeeee" in the following text is misrecognized as "pre".
<pre>
<preeeee>
aaaaaaa
</preeeee>
</pre>
!{width: 227px; border: 1px solid #ccc;}.pre-parse-bug@2x.png!
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
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.
<pre><code class="diff">
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
</code></pre>
--------------------------------------------------------------------------------
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?
--------------------------------------------------------------------------------
!{width: 252px; border: 1px solid #ccc;}.8395-note4.png!
--------------------------------------------------------------------------------
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.
<pre><code class="diff">
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
</code></pre>
Could you please try the new patch again?
--------------------------------------------------------------------------------
LGTM. The patch can be applied to the trunk and 3.4-stable cleanly. Setting target version to 3.4.7.
--------------------------------------------------------------------------------
Attached a test case for this issue.
Another way to fix this is to add to the regex the word boundary (\b):
<pre><code class="diff">
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
</code></pre>
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Committed #8395#note-9. Thank you all for the contribution.
--------------------------------------------------------------------------------
related_issues
relates,Closed,7375,<pre> ... </pre> doesn't escape wiki syntax correctly
duplicates,Closed,7309,'<pre/>' tag