]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/3152'
authorTom Hughes <tom@compton.nu>
Wed, 24 Mar 2021 21:14:41 +0000 (21:14 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 24 Mar 2021 21:14:41 +0000 (21:14 +0000)
config/initializers/sanitize.rb
test/lib/rich_text_test.rb

index b98523805a3e188806dd0eed7aaacc3d5449a6e2..d6bd6c3ee780c517ab0325f19279f8a2b82b1b4c 100644 (file)
@@ -5,6 +5,7 @@ Sanitize::Config::OSM = Sanitize::Config.merge(
   :remove_contents => %w[script style],
   :transformers => lambda do |env|
     env[:node].remove_class
+    env[:node].kwattr_remove("style", nil)
     env[:node].add_class("table table-sm w-auto") if env[:node_name] == "table"
   end
 )
index 5b590bc3e41ae1a60253884ff1154622af7c436e..fc9355717565018f02612962663fbd7eb6c5cd4d 100644 (file)
@@ -58,6 +58,12 @@ class RichTextTest < ActiveSupport::TestCase
       assert_select "p[class='btn btn-warning']", false
       assert_select "p", /^Click Me$/
     end
+
+    r = RichText.new("html", "<p style='color:red'>Danger</p>")
+    assert_html r do
+      assert_select "p[style='color:red']", false
+      assert_select "p", /^Danger$/
+    end
   end
 
   def test_html_to_text
@@ -163,11 +169,16 @@ class RichTextTest < ActiveSupport::TestCase
     end
 
     r = RichText.new("markdown", "Click Me\n{:.btn.btn-warning}")
-    # raise r.to_html
     assert_html r do
       assert_select "p[class='btn btn-warning']", false
       assert_select "p", /^Click Me$/
     end
+
+    r = RichText.new("markdown", "<p style='color:red'>Danger</p>")
+    assert_html r do
+      assert_select "p[style='color:red']", false
+      assert_select "p", /^Danger$/
+    end
   end
 
   def test_markdown_to_text