A platform for community discussion. Free, open, simple.
FIX: Remove 'reply above line' marker (#13927)
Bianca Nenciu54e2b95539c1
diff --git a/lib/email/receiver.rb b/lib/email/receiver.rbindex a6db1e27638..fc3361c43b5 100644--- a/lib/email/receiver.rb+++ b/lib/email/receiver.rb@@ -552,8 +552,13 @@ module Email@previous_replies_regex ||= /^--[- ]\n\*#{I18n.t("user_notifications.previous_discussion")}\*\n/imend+ def reply_above_line_regex+ @reply_above_line_regex ||= /\n#{I18n.t("user_notifications.reply_above_line")}\n/im+ end+def trim_discourse_markers(reply)- reply.split(previous_replies_regex)[0]+ reply = reply.split(previous_replies_regex)[0]+ reply.split(reply_above_line_regex)[0]enddef parse_from_field(mail = nil)diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rbindex 4f7820daac9..bd1cdd76009 100644--- a/spec/components/email/receiver_spec.rb+++ b/spec/components/email/receiver_spec.rb@@ -412,6 +412,11 @@ describe Email::Receiver doexpect(topic.posts.last.raw).to eq("This will not include the previous discussion that is present in this email.")end+ it "removes the 'type reply above' marker" do+ expect { process(:reply_above) }.to change { topic.posts.count }+ expect(topic.posts.last.raw).to eq("This will not include the previous discussion that is present in this email.")+ end+it "handles multiple paragraphs" doexpect { process(:paragraphs) }.to change { topic.posts.count }expect(topic.posts.last.raw).to eq("Do you like liquorice?\n\nI really like them. One could even say that I am *addicted* to liquorice. And if\nyou can mix it up with some anise, then I'm in heaven ;)")diff --git a/spec/fixtures/emails/reply_above.eml b/spec/fixtures/emails/reply_above.emlnew file mode 100644index 00000000000..04741efb491--- /dev/null+++ b/spec/fixtures/emails/reply_above.eml@@ -0,0 +1,15 @@+Return-Path: <[email protected]>+From: Foo Bar <[email protected]>+To: [email protected]+Date: Fri, 15 Jan 2016 00:12:43 +0100+Message-ID: <[email protected]>+Mime-Version: 1.0+Content-Type: text/html; charset=UTF-8++<p>This will not include the previous discussion that is present in this email.</p>++<div>+## Please type your reply above this line. ##+</div>++<div>previous discussion</div>