def sanitize_html(post) return nil if post.body.nil? html = post.body.gsub(/^\s*<\!\[CDATA\[/,'') document = Hpricot(html, :fixup_tags=>true) document.search('script,style,link').remove document.search('a,img').each do |osi| [:href,:src].each do |attr_name| next if osi[attr_name].nil? url = osi[attr_name].lstrip next if url.match(/^(\s|%20)*(f|ht)tps?:\/\//) if post.feed osi[attr_name] = begin URI.join(post.feed.link, url).to_s rescue 'http://' end end end end #plushs "S" document.to_s end