summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhttp://jneen.net/ <jneen@jneen.net>2016-12-13 12:14:38 -0800
committerhttp://jneen.net/ <jneen@jneen.net>2016-12-21 09:51:42 -0800
commitf02f238d52f061ee386438fb8bbe14b379e41f42 (patch)
tree67741437ba5387f4351c8a1d14de6ee6894adb95
parent56031276993347a7fba542c67c640fdae79df716 (diff)
downloadgitlab-ce-f02f238d52f061ee386438fb8bbe14b379e41f42.tar.gz
Revert "allow empty-quotes"
This reverts commit 4f2f678aff8d7dfcac96c47cf7eb480a5707ddaf.
-rw-r--r--lib/gitlab/email/reply_parser.rb4
-rw-r--r--spec/fixtures/emails/no_content_reply.eml (renamed from spec/fixtures/emails/empty_quote.eml)0
-rw-r--r--spec/lib/gitlab/email/reply_parser_spec.rb19
3 files changed, 6 insertions, 17 deletions
diff --git a/lib/gitlab/email/reply_parser.rb b/lib/gitlab/email/reply_parser.rb
index 96d0a4f5153..971afe4a878 100644
--- a/lib/gitlab/email/reply_parser.rb
+++ b/lib/gitlab/email/reply_parser.rb
@@ -18,6 +18,10 @@ module Gitlab
# not using /\s+$/ here because that deletes empty lines
body = body.gsub(/[ \t]$/, '')
+ # TODO [jneen]: do we want to allow empty-quoting? (replies only containing a blockquote)
+ # EmailReplyTrimmer allows this as a special case, 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")
end
diff --git a/spec/fixtures/emails/empty_quote.eml b/spec/fixtures/emails/no_content_reply.eml
index 95eb2055ce6..95eb2055ce6 100644
--- a/spec/fixtures/emails/empty_quote.eml
+++ b/spec/fixtures/emails/no_content_reply.eml
diff --git a/spec/lib/gitlab/email/reply_parser_spec.rb b/spec/lib/gitlab/email/reply_parser_spec.rb
index 138ad814262..28698e89c33 100644
--- a/spec/lib/gitlab/email/reply_parser_spec.rb
+++ b/spec/lib/gitlab/email/reply_parser_spec.rb
@@ -15,23 +15,8 @@ describe Gitlab::Email::ReplyParser, lib: true do
expect(test_parse_body("asdf" * 30)).to eq("")
end
- it "returns the quote for an empty-quoted comment" do
- expect(test_parse_body(fixture_file("emails/empty_quote.eml")))
- .to eq(<<-BODY.strip_heredoc.chomp)
- >
- >
- >
- > eviltrout posted in 'Adventure Time Sux' on Discourse Meta:
- >
- > ---
- > hey guys everyone knows adventure time sucks!
- >
- > ---
- > Please visit this link to respond: http://localhost:3000/t/adventure-time-sux/1234/3
- >
- > To unsubscribe from these emails, visit your [user preferences](http://localhost:3000/user_preferences).
- >
- BODY
+ it "returns an empty string if there is no reply content" do
+ expect(test_parse_body(fixture_file("emails/no_content_reply.eml"))).to eq("")
end
it "properly renders plaintext-only email" do