Sha256: 28b4b622ef7e9875b643fb31a50296d2c31615f68d0fee0c2654e2c7f7eb2ba7
Contents?: true
Size: 1.59 KB
Versions: 3
Compression:
Stored size: 1.59 KB
Contents
module MList module Util module EmailHelpers def sanitize_header(charset, name, *values) header_sanitizer(name).call(charset, *values) end def header_sanitizer(name) Util.default_header_sanitizers[name] end def normalize_new_lines(text) text.to_s.gsub(/\r\n?/, "\n") end BRACKETS_RE = /\A<(.*?)>\Z/ def bracket(string) string.blank? || string =~ BRACKETS_RE ? string : "<#{string}>" end def remove_brackets(string) string =~ BRACKETS_RE ? $1 : string end def remove_regard(string) stripped = string.strip stripped =~ /\A.*re:\s+(\[.*\]\s*)?(.*?)\Z/i ? $2 : stripped end def text_to_html(text) lines = normalize_new_lines(text).split("\n") lines.collect! do |line| line = escape_once(line) line = (" " * $1.length) + $2 if line =~ /^(\s+)(.*?)$/ line = %{<span class="quote">#{line}</span>} if line =~ /^(>|[|]|[A-Za-z]+>)/ line = line.gsub(/\s\s/, ' ') line end lines.join("<br />\n") end def text_to_quoted(text) lines = normalize_new_lines(text).split("\n") lines.collect! do |line| '> ' + line end lines.join("\n") end HTML_ESCAPE = { '&' => '&', '>' => '>', '<' => '<', '"' => '"' } def escape_once(text) text.gsub(/[\"><]|&(?!([a-zA-Z]+|(#\d+));)/) { |special| HTML_ESCAPE[special] } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
aiwilliams-mlist-0.1.2 | lib/mlist/util/email_helpers.rb |
aiwilliams-mlist-0.1.3 | lib/mlist/util/email_helpers.rb |
aiwilliams-mlist-0.1.4 | lib/mlist/util/email_helpers.rb |