From 899fc2e0cd2bcb4f5f9333b612b160bb9c6e803b Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 16 Nov 2019 09:47:01 +0000 Subject: [PATCH] Merged r18247 to 3.3-stable (#31520). git-svn-id: http://svn.redmine.org/redmine/branches/3.3-stable@19075 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redcloth3.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/redcloth3.rb b/lib/redcloth3.rb index d0bd217d3..2f62f9333 100644 --- a/lib/redcloth3.rb +++ b/lib/redcloth3.rb @@ -1213,7 +1213,13 @@ class RedCloth3 < String ALLOWED_TAGS = %w(redpre pre code kbd notextile) def escape_html_tags(text) - text.gsub!(%r{<(\/?([!\w]+)[^<>\n]*)(>?)}) {|m| ALLOWED_TAGS.include?($2) ? "<#{$1}#{$3}" : "<#{$1}#{'>' unless $3.blank?}" } + text.gsub!(%r{<(\/?([!\w]+)[^<>\n]*)(>?)}) do |m| + if ALLOWED_TAGS.include?($2) && $3.present? + "<#{$1}#{$3}" + else + "<#{$1}#{'>' unless $3.blank?}" + end + end end end