Test::Unit::TestCase
# File lib/feed_tools/vendor/html5/tests/test_sanitizer.rb, line 34 def check_sanitization(input, htmloutput, xhtmloutput, rexmloutput) assert_equal htmloutput, sanitize_html(input) assert_equal xhtmloutput, sanitize_xhtml(input) assert_equal rexmloutput, sanitize_rexml(input) end
# File lib/feed_tools/vendor/html5/tests/test_sanitizer.rb, line 18 def sanitize_html stream HTMLParser.parse_fragment(stream, {:tokenizer => HTMLSanitizer, :encoding => 'utf-8', :lowercase_element_name => false, :lowercase_attr_name => false}).to_s end
# File lib/feed_tools/vendor/html5/tests/test_sanitizer.rb, line 22 def sanitize_rexml stream require 'rexml/document' doc = REXML::Document.new("<div xmlns='http://www.w3.org/1999/xhtml'>#{stream}</div>") tokens = TreeWalkers.get_tree_walker('rexml').new(doc) XHTMLSerializer.serialize(tokens, {:encoding=>'utf-8', :quote_char => "'", :inject_meta_charset => false, :sanitize => true}).gsub(/\A<div xmlns='http:\/\/www.w3.org\/1999\/xhtml'>(.*)<\/div>\Z/, '\1') rescue REXML::ParseException return "Ill-formed XHTML!" end
# File lib/feed_tools/vendor/html5/tests/test_sanitizer.rb, line 14 def sanitize_xhtml stream XHTMLParser.parse_fragment(stream, {:tokenizer => HTMLSanitizer, :encoding => 'utf-8', :lowercase_element_name => false, :lowercase_attr_name => false}).to_s end
# File lib/feed_tools/vendor/html5/tests/test_sanitizer.rb, line 113 def test_should_handle_astral_plane_characters input = "<p>𝒵 𝔸</p>" output = "<p>\3360\2235\2222\2265 \3360\2235\2224\2270</p>" check_sanitization(input, output, output, output) input = "<p><tspan>\3360\2235\2224\2270</tspan> a</p>" output = "<p><tspan>\3360\2235\2224\2270</tspan> a</p>" check_sanitization(input, output, output, output) end
Generated with the Darkfish Rdoc Generator 2.