Module: FeedNormalizer::ElementCleaner
Instance Method Summary collapse
-
#clean! ⇒ Object
Recursively cleans all elements in place.
Instance Method Details
#clean! ⇒ Object
Recursively cleans all elements in place.
Only allow tags in whitelist. Always parse the html with a parser and delete all tags that arent on the list.
For feed elements that can contain HTML:
-
feed.(title|description)
-
feed.entries.(title|description|content)
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/structures.rb', line 102 def clean! self.class::SIMPLE_ELEMENTS.each do |element| val = self.send(element) send("#{element}=", (val.is_a?(Array) ? val.collect{|v| HtmlCleaner.flatten(v.to_s)} : HtmlCleaner.flatten(val.to_s))) end self.class::HTML_ELEMENTS.each do |element| send("#{element}=", HtmlCleaner.clean(self.send(element).to_s)) end self.class::BLENDED_ELEMENTS.each do |element| self.send(element).collect{|v| v.clean!} end end |