Use XHTMLSerializer, where appropriate.

This commit is contained in:
Jacques Distler 2007-07-04 18:53:03 -05:00
parent 8ccaad85a5
commit 1bc5da0053
2 changed files with 2 additions and 10 deletions

View file

@ -99,12 +99,8 @@ module Sanitize
#
def sanitize_rexml(tree)
tokens = TreeWalkers.getTreeWalker('rexml').new(tree.to_ncr)
HTMLSerializer.serialize(tokens, {:encoding=>'utf-8',
:quote_attr_values => true,
:minimize_boolean_attributes => false,
:use_trailing_solidus => true,
XHTMLSerializer.serialize(tokens, {:encoding=>'utf-8',
:space_before_trailing_solidus => true,
:omit_optional_tags => false,
:inject_meta_charset => false,
:sanitize => true})
end

View file

@ -23,12 +23,8 @@ class SanitizeTest < Test::Unit::TestCase
require 'rexml/document'
doc = REXML::Document.new("<div xmlns='http://www.w3.org/1999/xhtml'>#{stream}</div>")
tokens = TreeWalkers.getTreeWalker('rexml').new(doc)
HTMLSerializer.serialize(tokens, {:encoding=>'utf-8',
:quote_attr_values => true,
XHTMLSerializer.serialize(tokens, {:encoding=>'utf-8',
:quote_char => "'",
:minimize_boolean_attributes => false,
:use_trailing_solidus => true,
:omit_optional_tags => false,
:inject_meta_charset => false,
:sanitize => true}).gsub(/\A<div xmlns='http:\/\/www.w3.org\/1999\/xhtml'>(.*)<\/div>\Z/m, '\1')
rescue REXML::ParseException