1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-02-05 16:43:25 +00:00

Strip leading spaces to prevent lines from being rendered as pre tags.

git-svn-id: http://svn.redmine.org/redmine/trunk@14318 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2015-06-16 18:42:52 +00:00
parent c88ecf0e93
commit 76536474b0

View File

@ -436,7 +436,7 @@ class MailHandler < ActionMailer::Base
body = Redmine::CodesetUtil.to_utf8(p.body.decoded, body_charset)
# convert html parts to text
p.mime_type == 'text/html' ? self.class.html_body_to_text(body) : body
p.mime_type == 'text/html' ? self.class.html_body_to_text(body) : self.class.plain_text_body_to_text(body)
end.join("\r\n")
@plain_text_body
@ -456,6 +456,13 @@ class MailHandler < ActionMailer::Base
Redmine::WikiFormatting.html_parser.to_text(html)
end
# Converts a plain/text email body to text
def self.plain_text_body_to_text(text)
# Removes leading spaces that would cause the line to be rendered as
# preformatted text with textile
text.gsub(/^ +(?![*#])/, '')
end
def self.assign_string_attribute_with_limit(object, attribute, value, limit=nil)
limit ||= object.class.columns_hash[attribute.to_s].limit || 255
value = value.to_s.slice(0, limit)