summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-06-16 18:42:52 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-06-16 18:42:52 +0000
commit76536474b063c33c15ddf8cb7678709084d12892 (patch)
treecfe3b3028f930af838567309fc21b7a3cbad2e6d /app
parentc88ecf0e938f6badd7cd96d8041a707e02d13f55 (diff)
downloadredmine-76536474b063c33c15ddf8cb7678709084d12892.tar.gz
redmine-76536474b063c33c15ddf8cb7678709084d12892.zip
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
Diffstat (limited to 'app')
-rw-r--r--app/models/mail_handler.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index 5ea370e2a..0696216b1 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -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)