プロジェクト

全般

プロフィール

Vote #69936

完了

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

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Text formatting_26
対象バージョン:
開始日:
2011/05/18
期日:
進捗率:

0%

予定工数:
category_id:
26
version_id:
143
issue_org_id:
8395
author_id:
21519
assigned_to_id:
332
comments:
13
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
34
ステータス-->[Closed]

説明

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}" : "&lt;#{$1}#{'&gt;' 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

Admin Redmine さんが3年以上前に更新

  • カテゴリText formatting_26 にセット
  • 対象バージョン3.4.7_143 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0