Permalink
Browse files

outputting the document as xml

  • Loading branch information...
1 parent 29b0c82 commit 7881cf3c46912397e17a8156a98370c4d57c9333 @tenderlove tenderlove committed Jan 20, 2009
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/dryopteris/sanitize.rb
@@ -28,7 +28,7 @@ def sanitize(string_or_io, encoding=nil)
body.children.each do |node|
traverse_conditionally_top_down(node, :sanitize_node)
end
- body.inner_html
+ body.children.map { |x| x.to_xml }.join
end
private
@@ -54,7 +54,7 @@ def sanitize_node(node)
node.attributes.each do |attr|
if HashedWhiteList::ATTR_VAL_IS_URI[attr.first]
# this block lifted nearly verbatim from HTML5 sanitization
- val_unescaped = CGI.unescapeHTML(attr.last).gsub(/`|[\000-\040\177\s]+|\302[\200-\240]/,'').downcase
+ val_unescaped = CGI.unescapeHTML(attr.last.to_s).gsub(/`|[\000-\040\177\s]+|\302[\200-\240]/,'').downcase
if val_unescaped =~ /^[a-z0-9][-+.a-z0-9]*:/ and HashedWhiteList::ALLOWED_PROTOCOLS[val_unescaped.split(':')[0]].nil?
node.remove_attribute(attr.first)
end

0 comments on commit 7881cf3

Please sign in to comment.