def filter_html(html,profile='')
unless profile.class.to_s == 'Hash'
profile=get_profile
end
if html.index('<')
tokenizer = HTML::Tokenizer.new(html)
new_text=''
while token = tokenizer.next
node=HTML::Node.parse(nil, 0, 0, token, false)
if node.class.to_s == 'HTML::Tag' && profile[node.name]
allowed_attributes=filter_attributes(node,profile[node.name])
new_node=HTML::Tag.new(node.parent, node.line, node.position, node.name, allowed_attributes, node.closing)
new_text << new_node.to_s
else
new_text << node.to_s.gsub(/</,'&LT;')
end
end
html = new_text
end
return html
end