summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2023-09-18 08:15:54 +0000
committerGo MAEDA <maeda@farend.jp>2023-09-18 08:15:54 +0000
commit16368edc12cfb9dbb7ebe93cda50d84ff7d7c581 (patch)
tree3124b60ba68d6c36f5338476175cf37d791887db
parentc69e2adf76cac483c143bc9aa7d7e38e67b42c11 (diff)
downloadredmine-16368edc12cfb9dbb7ebe93cda50d84ff7d7c581.tar.gz
redmine-16368edc12cfb9dbb7ebe93cda50d84ff7d7c581.zip
Merged r22302 and r22303 from trunk to 4.2-stable (#38807).
git-svn-id: https://svn.redmine.org/redmine/branches/4.2-stable@22305 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--lib/redmine/wiki_formatting/textile/redcloth3.rb8
-rw-r--r--test/helpers/application_helper_test.rb5
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb
index 532283e7e..569f719c5 100644
--- a/lib/redmine/wiki_formatting/textile/redcloth3.rb
+++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb
@@ -840,7 +840,7 @@ class RedCloth3 < String
end
url = htmlesc(url.dup)
- next all if url.downcase.start_with?('javascript:')
+ next all unless uri_with_link_safe_scheme?(url)
atts = pba(atts)
atts = +" href=\"#{url}#{slash}\"#{atts}"
@@ -964,7 +964,7 @@ class RedCloth3 < String
next m unless uri_with_safe_scheme?(url.partition('?').first)
if href
href = htmlesc(href.dup)
- next m if href.downcase.start_with?('javascript:')
+ next m unless uri_with_link_safe_scheme?(href)
end
out = +''
@@ -1213,9 +1213,9 @@ class RedCloth3 < String
all, tag, close = $1, $2, $3
if close.present? && (ALLOWED_TAGS.include?(tag) || (tag =~ /\Aredpre#\d+\z/))
- "<#{all}#{close}"
+ "<#{htmlesc all}#{close}"
else
- "&lt;#{all}#{'&gt;' unless close.blank?}"
+ "&lt;#{htmlesc all}#{'&gt;' unless close.blank?}"
end
end
end
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index 617c79c6e..b7c28c10e 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -1220,12 +1220,13 @@ class ApplicationHelperTest < Redmine::HelperTest
def test_html_tags
to_test = {
"<div>content</div>" => "<p>&lt;div&gt;content&lt;/div&gt;</p>",
- "<div class=\"bold\">content</div>" => "<p>&lt;div class=\"bold\"&gt;content&lt;/div&gt;</p>",
+ "<div class=\"bold\">content</div>" => "<p>&lt;div class=&quot;bold&quot;&gt;content&lt;/div&gt;</p>",
"<script>some script;</script>" => "<p>&lt;script&gt;some script;&lt;/script&gt;</p>",
# do not escape pre/code tags
"<pre>\nline 1\nline2</pre>" => "<pre>\nline 1\nline2</pre>",
"<pre><code>\nline 1\nline2</code></pre>" => "<pre><code>\nline 1\nline2</code></pre>",
- "<pre><div>content</div></pre>" => "<pre>&lt;div&gt;content&lt;/div&gt;</pre>",
+ "<pre><div class=\"foo\">content</div></pre>" => "<pre>&lt;div class=\"foo\"&gt;content&lt;/div&gt;</pre>",
+ "<pre><div class=\"<foo\">content</div></pre>" => "<pre>&lt;div class=\"&lt;foo\"&gt;content&lt;/div&gt;</pre>",
"HTML comment: <!-- no comments -->" => "<p>HTML comment: &lt;!-- no comments --&gt;</p>",
"<!-- opening comment" => "<p>&lt;!-- opening comment</p>",
# remove attributes including class