Use XHTMLSerializer, where appropriate.
This commit is contained in:
parent
8ccaad85a5
commit
1bc5da0053
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue