sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit cd8b84ae6610e6f5b62cd28a4d86c055893d20f6
parent 1b818eafa902e485d279329c3c5aeab632007e0a
Author: Dan Callaghan <djc@djc.id.au>
Date:   Sun, 21 Jun 2020 14:52:23 +1000

tests: add a case to cover Zimbra block quote with bottom-post

Diffstat:
A test/fixtures/zimbra-quote-with-bottom-post.eml | 27 +++++++++++++++++++++++++++
M test/test_message.rb | 29 +++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/test/fixtures/zimbra-quote-with-bottom-post.eml b/test/fixtures/zimbra-quote-with-bottom-post.eml
@@ -0,0 +1,27 @@
+Return-Path: <zimbra.user@example.invalid>
+Delivered-To: <recipient@example.invalid>
+Received: from zmail16.collab.prod.int.phx2.redhat.com (zmail16.collab.prod.int.phx2.redhat.com [10.5.83.18])
+    by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q3A5xQ06025053
+    for <recipient@example.invalid>; Tue, 10 Apr 2012 01:59:26 -0400
+Date: Tue, 10 Apr 2012 01:59:26 -0400 (EDT)
+From: Zimbra User <zimbra.user@example.invalid>
+To: Recipient <recipient@example.invalid>
+Subject: Re: Zimbra
+Message-ID: <0fe105df-e67b-419e-8599-50aaff7260e8@zmail16.collab.prod.int.phx2.redhat.com>
+In-Reply-To: <1334037315-sup-8577@example.invalid>
+Content-Type: text/plain; charset=utf-8
+Content-Transfer-Encoding: 7bit
+MIME-Version: 1.0
+X-Mailer: Zimbra 7.1.2_GA_3268 (ZimbraWebClient - FF3.0 (Linux)/7.1.2_GA_3268)
+
+----- Original Message -----
+> From: "Recipient" <recipient@example.invalid>
+> To: "Zimbra User" <zimbra.user@example.invalid>
+> Sent: Tuesday, April 10, 2012 3:56:15 PM
+> Subject: Re: Zimbra
+>
+> This is the quoted original message.
+>
+
+
+This is the reply from the Zimbra user.
diff --git a/test/test_message.rb b/test/test_message.rb
@@ -225,6 +225,35 @@ class TestMessage < Minitest::Test
   # TODO: test different quoting styles, see that they are all divided
   # to chunks properly
 
+  def test_zimbra_quote_with_bottom_post
+    # Zimbra does an Outlook-style "Original Message" delimiter and then *also*
+    # prefixes each quoted line with a > marker. That's okay until the sender
+    # tries to do the right thing and reply after the quote.
+    # In this case we want to just look at the > markers when determining where
+    # the quoted chunk ends.
+    message = fixture('zimbra-quote-with-bottom-post.eml')
+
+    source = DummySource.new("sup-test://test_zimbra_quote_with_bottom_post")
+    source.messages = [ message ]
+    source_info = 0
+
+    sup_message = Message.build_from_source(source, source_info)
+    chunks = sup_message.load_from_source!
+
+    assert_equal(3, chunks.length)
+
+    # TODO this chunk should ideally be part of the quote chunk after it.
+    assert(chunks[0].is_a? Redwood::Chunk::Text)
+    assert_equal(1, chunks[0].lines.length)
+    assert_equal("----- Original Message -----", chunks[0].lines.first)
+
+    assert(chunks[1].is_a? Redwood::Chunk::Quote)
+
+    assert(chunks[2].is_a? Redwood::Chunk::Text)
+    assert_equal(3, chunks[2].lines.length)
+    assert_equal("This is the reply from the Zimbra user.",
+                 chunks[2].lines[2])
+  end
 end
 
 end