lib/galakei/email.rb in galakei-0.9.0 vs lib/galakei/email.rb in galakei-0.9.1

- old
+ new

@@ -8,13 +8,18 @@ /^.+@[dhtcrknsq]\.vodafone\.ne\.jp$/, /^.+@jp-[dhtcrknsq]\.ne\.jp$/, /^.+@emnet\.ne\.jp$/, /^.+@docomo\.ne\.jp$/ ] - SANITIZE_OPTIONS = { - :elements => %w{br a div hr}, - :attributes => {'a' => ['href'] }, + SANITIZE_OPTIONS = { + :elements => %w{font blink marquee br a div hr}, + :attributes => {'a' => ['href'], + 'font' => ['size','color'], + 'marquee' => ['behaviour'], + 'hr' => ['color'], + 'div' => ['align'], + }, :protocols => {'a' => {'href' => ['http', 'https', 'mailto']}}, :whitespace_elements => [] } TAGS_TO_PROCESS = %w{h1 h2 h3 h4 h5 h6 p}.join(',') @@ -27,12 +32,12 @@ doc = Nokogiri::HTML(html_email) doc.css(TAGS_TO_PROCESS).each do |node| node.name = "div" node.after("<br />") end - + encoding = doc.meta_encoding || "UTF-8" res = "<html><head>" - res << "<meta http-equiv=\"Content-type\" content=\"text/html;charset=#{doc.meta_encoding}\" />" + res << "<meta http-equiv=\"Content-type\" content=\"text/html;charset=#{encoding}\" />" res << "</head><body>" res << Sanitize.clean(doc.to_s, SANITIZE_OPTIONS) res << "</body></html>" end