]> source.dussan.org Git - redmine.git/commitdiff
Merged r21850 and r21851 from trunk to 5.0-stable (#37237).
authorMarius Balteanu <marius.balteanu@zitec.com>
Tue, 27 Sep 2022 17:11:53 +0000 (17:11 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Tue, 27 Sep 2022 17:11:53 +0000 (17:11 +0000)
git-svn-id: https://svn.redmine.org/redmine/branches/5.0-stable@21859 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/wiki_formatting/common_mark/sanitization_filter.rb
public/help/en/wiki_syntax_detailed_common_mark.html
test/unit/lib/redmine/wiki_formatting/common_mark/sanitization_filter_test.rb

index 7fef35bfae6c6e4547b1fe3a203f6b73fd7e7db1..b1f1cfe01c6f051a1db9c18a6be11b6eead89579 100644 (file)
@@ -27,6 +27,18 @@ module Redmine
           "a" => %w(href).freeze,
         }.freeze
 
+        ALLOWED_CSS_PROPERTIES = %w[
+          color background-color
+          width
+          height
+          padding padding-left padding-right padding-top padding-bottom
+          margin margin-left margin-right margin-top margin-bottom
+          border border-left border-right border-top border-bottom border-radius border-style border-collapse border-spacing
+          font font-style font-variant font-weight font-stretch font-size line-height font-family
+          text-align
+          float
+        ].freeze
+
         def allowlist
           @allowlist ||= customize_allowlist(super.deep_dup)
         end
@@ -40,6 +52,9 @@ module Redmine
           allowlist[:attributes][:all].delete("name")
           allowlist[:attributes]["a"].push("name")
 
+          allowlist[:attributes][:all].push("style")
+          allowlist[:css] = { properties: ALLOWED_CSS_PROPERTIES }
+
           # allow class on code tags (this holds the language info from fenced
           # code bocks and has the format language-foo)
           allowlist[:attributes]["code"] = %w(class)
index 087fa6f0510e6e1fb0830fbc2a222b70de6a42e4..74c1dd2ef9a7d97009503c6d8127bfee97366c96 100644 (file)
@@ -356,6 +356,19 @@ It can be expanded by clicking a link.
 <tr><td align="center" colspan="2">bar</td></tr>
 </table>
 
+<p>The <strong>style</strong> attribute can be used in raw HTML to apply custom formatting. The following CSS properties are allowed:</p>
+<pre><code>
+  color background-color
+  width
+  height
+  padding padding-left padding-right padding-top padding-bottom
+  margin margin-left margin-right margin-top margin-bottom
+  border border-left border-right border-top border-bottom border-radius border-style border-collapse border-spacing
+  font font-style font-variant font-weight font-stretch font-size line-height font-family
+  text-align
+  float
+</code></pre>
+
 </body>
 </html>
 
index 8cd6074ee4d8098542fae4a1e28cf10d5e1bfec3..06372741390a8a43f741d3a8e96a770509e39acc 100644 (file)
@@ -93,6 +93,10 @@ if Object.const_defined?(:CommonMarker)
     # samples taken from the Sanitize test suite
     # rubocop:disable Layout/LineLength
     STRINGS = [
+      [
+        '<span style="color: #333; background: url(\'https://example.com/evil.svg\')">hello</span>"',
+        '<span style="color: #333; ">hello</span>"'
+      ],
       [
         '<b>Lo<!-- comment -->rem</b> <a href="pants" title="foo" style="text-decoration: underline;">ipsum</a> <a href="http://foo.com/"><strong>dolor</strong></a> sit<br/>amet <style>.foo { color: #fff; }</style> <script>alert("hello world");</script>',
         '<b>Lorem</b> <a href="pants" title="foo">ipsum</a> <a href="http://foo.com/"><strong>dolor</strong></a> sit<br>amet .foo { color: #fff; } '