Commit 602c3198 authored by http://jneen.net/'s avatar http://jneen.net/

allow empty-quotes

parent 017579fe
...@@ -18,10 +18,6 @@ module Gitlab ...@@ -18,10 +18,6 @@ module Gitlab
# [jneen] not using /\s+$/ here because that deletes empty lines # [jneen] not using /\s+$/ here because that deletes empty lines
body = body.gsub(/[ \t]$/, '') 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") body.force_encoding(encoding).encode("UTF-8")
end end
......
...@@ -15,8 +15,23 @@ describe Gitlab::Email::ReplyParser, lib: true do ...@@ -15,8 +15,23 @@ describe Gitlab::Email::ReplyParser, lib: true do
expect(test_parse_body("asdf" * 30)).to eq("") expect(test_parse_body("asdf" * 30)).to eq("")
end end
it "returns an empty string if there is no reply content" do it "returns the quote for an empty-quoted comment" do
expect(test_parse_body(fixture_file("emails/no_content_reply.eml"))).to eq("") 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 end
it "properly renders plaintext-only email" do it "properly renders plaintext-only email" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment