diff options
author | heavysixer <heavysixer@gmail.com> | 2008-10-25 13:33:39 -0500 |
---|---|---|
committer | heavysixer <heavysixer@gmail.com> | 2008-10-25 13:33:39 -0500 |
commit | 14f05140e53f4f58bc86ee08b9a4ba836c14f9be (patch) | |
tree | 03b975c55bb42b964edc8a3507f63f92487a42ed /actionpack/test/controller/html-scanner/sanitizer_test.rb | |
parent | 35f29f7ea5ba183e49e26367cc31649ff4bd0e97 (diff) | |
parent | 650aa015789c704ca8ea864f1117faf3f404a59b (diff) | |
download | rails-14f05140e53f4f58bc86ee08b9a4ba836c14f9be.tar.gz rails-14f05140e53f4f58bc86ee08b9a4ba836c14f9be.tar.bz2 rails-14f05140e53f4f58bc86ee08b9a4ba836c14f9be.zip |
Merge branch 'master' of git@github.com:lifo/docrails
Diffstat (limited to 'actionpack/test/controller/html-scanner/sanitizer_test.rb')
-rw-r--r-- | actionpack/test/controller/html-scanner/sanitizer_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/actionpack/test/controller/html-scanner/sanitizer_test.rb b/actionpack/test/controller/html-scanner/sanitizer_test.rb index db142f0bc6..a9e8447e32 100644 --- a/actionpack/test/controller/html-scanner/sanitizer_test.rb +++ b/actionpack/test/controller/html-scanner/sanitizer_test.rb @@ -17,6 +17,8 @@ class SanitizerTest < Test::Unit::TestCase %{This is a test.\n\n\nIt no longer contains any HTML.\n}, sanitizer.sanitize( %{<title>This is <b>a <a href="" target="_blank">test</a></b>.</title>\n\n<!-- it has a comment -->\n\n<p>It no <b>longer <strong>contains <em>any <strike>HTML</strike></em>.</strong></b></p>\n})) assert_equal "This has a here.", sanitizer.sanitize("This has a <!-- comment --> here.") + assert_equal "This has a here.", sanitizer.sanitize("This has a <![CDATA[<section>]]> here.") + assert_equal "This has an unclosed ", sanitizer.sanitize("This has an unclosed <![CDATA[<section>]] here...") [nil, '', ' '].each { |blank| assert_equal blank, sanitizer.sanitize(blank) } end @@ -243,6 +245,14 @@ class SanitizerTest < Test::Unit::TestCase assert_sanitized %(<img src='vbscript:msgbox("XSS")' />), '<img />' end + def test_should_sanitize_cdata_section + assert_sanitized "<![CDATA[<span>section</span>]]>", "<![CDATA[<span>section</span>]]>" + end + + def test_should_sanitize_unterminated_cdata_section + assert_sanitized "<![CDATA[<span>neverending...", "<![CDATA[<span>neverending...]]>" + end + protected def assert_sanitized(input, expected = nil) @sanitizer ||= HTML::WhiteListSanitizer.new |