Class: FeedParserUtilities::SanitizerDoc

Inherits:
Hpricot::Doc
  • Object
show all
Defined in:
lib/rfeedparser/scrub.rb

Instance Method Summary collapse

Instance Method Details

#scrubObject



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/rfeedparser/scrub.rb', line 164

def scrub
  traverse_all_element do |e| 
	if e.elem? 
	  if Acceptable_Elements.include?e.name
 e.strip_attributes
	  else
 if Unacceptable_Elements_With_End_Tag.include?e.name
   e.inner_html = ''
 end
 e.swap(SanitizerDoc.new(e.children).scrub.to_html) # The important part
	  end
	elsif e.doctype?
	  e.parent.children.delete(e)
	elsif e.text?
	  ets = e.to_s
	  ets.gsub!(/'/, "'") 
 ets.gsub!(/"/, '"')
 ets.gsub!(/\r/,'')
	  e.swap(ets)
	else
	end
  end

  unless $compatible # FIXME nonworking
	# yes, that '/' should be there. It's a search method. See the Hpricot docs.
	(self/tag).strip_style(@config[:allow_css_properties], @config[:allow_css_keywords])
  end
  return self
end