summaryrefslogtreecommitdiffstats
path: root/lib/redmine
diff options
context:
space:
mode:
Diffstat (limited to 'lib/redmine')
-rw-r--r--lib/redmine/wiki_formatting/textile/redcloth3.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb
index 347743105..532283e7e 100644
--- a/lib/redmine/wiki_formatting/textile/redcloth3.rb
+++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb
@@ -1207,13 +1207,15 @@ class RedCloth3 < String
end
end
- ALLOWED_TAGS = %w(redpre pre code kbd notextile)
+ ALLOWED_TAGS = %w(pre code kbd notextile)
def escape_html_tags(text)
- text.gsub!(%r{<(\/?([!\w]+)[^<>\n]*)(>?)}) do |m|
- if ALLOWED_TAGS.include?($2) && $3.present?
- "<#{$1}#{$3}"
+ text.gsub!(%r{<(\/?([!\w][^ >\t\f\r\n]*)[^<>\n]*)(>?)}) do |m|
+ all, tag, close = $1, $2, $3
+
+ if close.present? && (ALLOWED_TAGS.include?(tag) || (tag =~ /\Aredpre#\d+\z/))
+ "<#{all}#{close}"
else
- "&lt;#{$1}#{'&gt;' unless $3.blank?}"
+ "&lt;#{all}#{'&gt;' unless close.blank?}"
end
end
end