diff options
Diffstat (limited to 'lib/rendering.rb')
-rw-r--r-- | lib/rendering.rb | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/rendering.rb b/lib/rendering.rb index 4d81197..5c164da 100644 --- a/lib/rendering.rb +++ b/lib/rendering.rb @@ -7,14 +7,14 @@ module Ag::Rendering if mail.multipart? content_type = mime_split(mail.parts.first.content_type) - if content_type == 'text/plain' or content_type == 'text/html' + if content_type == 'text/plain' || content_type == 'text/html' to_content(content_type, mail.parts.first.decoded, get_encoding(mail.parts.first)) else # Nested multipart? if mail.parts.first.multipart? content_type = mime_split(mail.parts.first.parts.first.content_type) - if content_type == 'text/plain' or content_type == 'text/html' + if content_type == 'text/plain' || content_type == 'text/html' to_content(content_type, mail.parts.first.parts.first.decoded, get_encoding(mail.parts.first.parts.first)) else raise "Cannot find body: #{mail.message_id}" @@ -26,7 +26,7 @@ module Ag::Rendering end else # No Content-Type, assume plain text (git-send-email) - if mail.content_type == nil + if mail.content_type.nil? to_content('text/plain', mail.body.decoded, get_encoding(mail)) else to_content(mime_split(mail.content_type), mail.body.decoded, get_encoding(mail)) @@ -35,18 +35,14 @@ module Ag::Rendering end def self.get_encoding(part) - if part.content_type_parameters - part.content_type_parameters['charset'] - else - nil - end + part.content_type_parameters['charset'] if part.content_type_parameters end - def self.to_content(content_type, content, charset = nil) - #content = content.force_encoding(charset) if charset + def self.to_content(content_type, content, _charset = nil) + # content = content.force_encoding(charset) if charset if content_type == 'text/plain' - escaped_content = CGI::escapeHTML(content) + escaped_content = CGI.escapeHTML(content) escaped_content.lines.map do |line| if line.start_with? '>' "<div class=\"ag-quote\">#{line.rstrip}</div>\n" |