diff options
author | http://jneen.net/ <jneen@jneen.net> | 2016-11-22 15:25:09 +0900 |
---|---|---|
committer | http://jneen.net/ <jneen@jneen.net> | 2016-12-21 09:51:41 -0800 |
commit | 602c3198626ae2a23f8f2962963c18f3b3bf1664 (patch) | |
tree | 8b1a5e1d3ad3fb58ac24244c436b56360d6aa1b2 | |
parent | 017579fe149e976fb0b2b21b234ea923913cadb2 (diff) | |
download | gitlab-ce-602c3198626ae2a23f8f2962963c18f3b3bf1664.tar.gz |
allow empty-quotes
-rw-r--r-- | lib/gitlab/email/reply_parser.rb | 4 | ||||
-rw-r--r-- | spec/fixtures/emails/empty_quote.eml (renamed from spec/fixtures/emails/no_content_reply.eml) | 0 | ||||
-rw-r--r-- | spec/lib/gitlab/email/reply_parser_spec.rb | 19 |
3 files changed, 17 insertions, 6 deletions
diff --git a/lib/gitlab/email/reply_parser.rb b/lib/gitlab/email/reply_parser.rb index e714923c4d8..5957cbbad7e 100644 --- a/lib/gitlab/email/reply_parser.rb +++ b/lib/gitlab/email/reply_parser.rb @@ -18,10 +18,6 @@ module Gitlab # [jneen] 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/no_content_reply.eml b/spec/fixtures/emails/empty_quote.eml index 95eb2055ce6..95eb2055ce6 100644 --- a/spec/fixtures/emails/no_content_reply.eml +++ b/spec/fixtures/emails/empty_quote.eml diff --git a/spec/lib/gitlab/email/reply_parser_spec.rb b/spec/lib/gitlab/email/reply_parser_spec.rb index 28698e89c33..138ad814262 100644 --- a/spec/lib/gitlab/email/reply_parser_spec.rb +++ b/spec/lib/gitlab/email/reply_parser_spec.rb @@ -15,8 +15,23 @@ describe Gitlab::Email::ReplyParser, lib: true do expect(test_parse_body("asdf" * 30)).to eq("") end - 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("") + 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 end it "properly renders plaintext-only email" do |