diff options
Diffstat (limited to 'lib/gitlab/email/reply_parser.rb')
-rw-r--r-- | lib/gitlab/email/reply_parser.rb | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/gitlab/email/reply_parser.rb b/lib/gitlab/email/reply_parser.rb index 3411eb1d9ce..1ad44425c93 100644 --- a/lib/gitlab/email/reply_parser.rb +++ b/lib/gitlab/email/reply_parser.rb @@ -23,19 +23,28 @@ module Gitlab private def select_body(message) - text = message.text_part if message.multipart? - text ||= message if message.content_type !~ /text\/html/ + if message.multipart? + text = message.text_part || message.html_part || message + else + text = message + end return "" unless text - text = fix_charset(text) + decoded = fix_charset(text) + + return "" unless decoded # Certain trigger phrases that means we didn't parse correctly - if text =~ /(Content\-Type\:|multipart\/alternative|text\/plain)/ + if decoded =~ /(Content\-Type\:|multipart\/alternative|text\/plain)/ return "" end - text + if text.content_type =~ %r(text/html) + HTMLParser.parse_reply(decoded) + else + decoded + end end # Force encoding to UTF-8 on a Mail::Message or Mail::Part |