diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /lib/gitlab/email/reply_parser.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'lib/gitlab/email/reply_parser.rb')
-rw-r--r-- | lib/gitlab/email/reply_parser.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/gitlab/email/reply_parser.rb b/lib/gitlab/email/reply_parser.rb index 7579f3d8680..0f0f4800062 100644 --- a/lib/gitlab/email/reply_parser.rb +++ b/lib/gitlab/email/reply_parser.rb @@ -6,20 +6,17 @@ module Gitlab class ReplyParser attr_accessor :message - def initialize(message, trim_reply: true) + def initialize(message, trim_reply: true, append_reply: false) @message = message @trim_reply = trim_reply + @append_reply = append_reply end def execute body = select_body(message) encoding = body.encoding - - if @trim_reply - body = EmailReplyTrimmer.trim(body) - end - + body, stripped_text = EmailReplyTrimmer.trim(body, @append_reply) if @trim_reply return '' unless body # not using /\s+$/ here because that deletes empty lines @@ -30,7 +27,10 @@ module Gitlab # so we detect it manually here. return "" if body.lines.all? { |l| l.strip.empty? || l.start_with?('>') } - body.force_encoding(encoding).encode("UTF-8") + encoded_body = body.force_encoding(encoding).encode("UTF-8") + return encoded_body unless @append_reply + + [encoded_body, stripped_text.force_encoding(encoding).encode("UTF-8")] end private |