notes: add sanitization tests.
This commit is contained in:
15
test/unit/note_sanitizer_test.rb
Normal file
15
test/unit/note_sanitizer_test.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'test_helper'
|
||||
|
||||
class NoteSanitizerTest < ActiveSupport::TestCase
|
||||
context "Sanitizing a note" do
|
||||
should "strip unsafe tags" do
|
||||
body = '<p>test</p> <script>alert("owned")</script>'
|
||||
assert_equal('<p>test</p> alert("owned")', NoteSanitizer.sanitize(body))
|
||||
end
|
||||
|
||||
should "strip unsafe css" do
|
||||
body = '<p style="background-image: url(http://www.google.com);">test</p>'
|
||||
assert_equal("<p>test</p>", NoteSanitizer.sanitize(body))
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user