Mailspring/packages/local-sync/spec/fixtures/MessageFactory/parseFromImap/eff-plaintext-no-mime.json
Christine Spang a23c68092e [local-sync] Add specs for message parsing
Summary:
This commit also fixes snippets for HTML-only messages to strip out HTML
tags, and makes us preserve whitespace for plaintext emails by
displaying them in <pre class="nylas-plaintext"> tags, and makes us log
messages that fail to parse at all to a tempdir.

The only issue I found with using <pre> tags for plaintext email was
that some lines may trigger scrolling, so there is an associated commit
(D3484) that changes the CSS for <pre class="nylas-plaintext"> to wrap
lines.

In the future, we can add regression tests to this test suite whenever
we fix parsing bugs.

Test Plan: unit tests included

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D3483
2016-12-07 07:25:28 -08:00

1 line
12 KiB
JSON

{"imapMessage":{"attributes":{"struct":[{"partID":"1","type":"text","subtype":"plain","params":null,"id":null,"description":null,"encoding":"7BIT","size":3050,"lines":67,"md5":null,"disposition":null,"language":null}],"date":"2016-12-01T01:34:44.000Z","flags":["\\Seen"],"uid":348040,"modseq":"8228548","x-gm-labels":["\\Inbox"],"x-gm-msgid":"1552475576878158784","x-gm-thrid":"1552475576878158784"},"headers":"Delivered-To: christine@spang.cc\r\nReceived: by 10.140.100.181 with SMTP id s50csp492441qge; Wed, 30 Nov 2016\r\n 17:34:44 -0800 (PST)\r\nX-Received: by 10.129.120.215 with SMTP id t206mr41825274ywc.39.1480556084610;\r\n Wed, 30 Nov 2016 17:34:44 -0800 (PST)\r\nReturn-Path: <www-data@web5.eff.org>\r\nReceived: from mail2.eff.org (mail2.eff.org. [173.239.79.204]) by\r\n mx.google.com with ESMTPS id c198si18454640ywb.136.2016.11.30.17.34.44 for\r\n <christine@spang.cc> (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 30\r\n Nov 2016 17:34:44 -0800 (PST)\r\nReceived-SPF: pass (google.com: best guess record for domain of\r\n www-data@web5.eff.org designates 173.239.79.204 as permitted sender)\r\n client-ip=173.239.79.204;\r\nAuthentication-Results: mx.google.com; dkim=pass header.i=@eff.org; spf=pass\r\n (google.com: best guess record for domain of www-data@web5.eff.org designates\r\n 173.239.79.204 as permitted sender) smtp.mailfrom=www-data@web5.eff.org;\r\n dmarc=pass (p=NONE dis=NONE) header.from=eff.org\r\nDKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=eff.org;\r\n s=mail2; h=Date:Message-Id:Sender:Reply-To:From:Subject:To;\r\n bh=85sXKrmP+EL3X9i986SKLxXpb0v60xG0c09b/uRaP10=;\r\n b=IByfHFGQGSbxCZfsWU5gd3ek92bd4yhEReZ8qDGPo/CWDCeUO3QnB6yY3aMpuJdD9TUUUKM6rcmfpz4zTmCtwkakMW/uIay2CBXUWuAsowRwUtofpIDmn4aDOhkMUHvyMZe9cZhpgWr7EC1JqEI+3J/kvhR/HTgi7r0dVnz7FBk=;\r\nReceived: from static-69.50.232.52.nephosdns.com ([69.50.232.52]:57896\r\n helo=web5.eff.org) by mail2.eff.org with esmtp (Exim 4.80) (envelope-from\r\n <www-data@web5.eff.org>) id 1cCGGo-000366-QC for christine@spang.cc; Wed, 30\r\n Nov 2016 17:34:42 -0800\r\nReceived: by web5.eff.org (Postfix, from userid 33) id BFBE132AD8C; Wed, 30\r\n Nov 2016 17:34:42 -0800 (PST)\r\nTo: christine@spang.cc\r\nSubject: EFF Membership Benefits\r\nFrom: Member Services <membership@eff.org>\r\nReply-To: membership@eff.org\r\nSender: membership@eff.org\r\nMessage-Id: <20161201013442.BFBE132AD8C@web5.eff.org>\r\nDate: Wed, 30 Nov 2016 17:34:42 -0800 (PST)\r\nReceived-SPF: skipped for local relay\r\n\r\n","parts":{"1":"Thank you for being a member of the Electronic Frontier Foundation! Your\r\nEFF membership lasts for 12 months and you have the opportunity to\r\nselect a free gift every time you renew! If you are a monthly donor,\r\nyour membership lasts as long as you like, and you are eligible for a\r\nmember gift every 12 months. Contributions are tax deductible as allowed\r\nby law. EFF is a U.S. 501(c)(3) organization, and our federal tax ID\r\nnumber is 04-3091431.\r\n\r\nYour contribution makes a significant difference in our ability to\r\ndefend your rights in the digital world whether that means standing up\r\nfor users in the courts, educating the public about dangerous laws, or\r\ncreating privacy-enhancing technologies. We are pleased to offer you a\r\nfew modest perks as a token of our thanks. This is a one-time email\r\nnotice and EFF will never share your information with partnering or\r\nsupporting organizations. Contact us at membership@eff.org if you have\r\nany questions!\r\n\r\nEFF MEMBER BENEFITS:\r\n\r\n-EFF Online Rights bumper sticker (via print mail).\r\n\r\n-EFF Member Card (via print mail).\r\n\r\n-Digital Badges: Show your support on your blog, website, or in an HTML\r\nemail signature.\r\nhttps://www.eff.org/files/2016/11/01/2017mb.png\r\n\r\n-Discounts on Events: Receive discounts on General Admission to EFF\r\nevents! Choose the member price when purchasing tickets or show your EFF\r\nMember card at the door. Watch for specific details in event invitations.\r\n\r\n-Speakeasy Invitations: Get notified about informal members-only meetups\r\nand drink ups with EFF lawyers, activists, and technologists in your area!\r\n\r\n-EFF Online Shop Discount: Get 10% off purchases (Gift Memberships\r\nexcluded) at EFF's online store by using the discount code ALIQUID16 at\r\nhttps://www.eff.org/shop.\r\n\r\nPARTNER DISCOUNTS FOR EFF MEMBERS:\r\n\r\n-LeanPub: Get a copy of Uncensored, an ever expanding collection of\r\nessays on Internet freedom from many of its original innovators. Follow\r\nthis promo url: http://leanpub.com/uncensored/c/effdonor.\r\n\r\n-Borderlands Books and Cafe: Borderlands is San Francisco's home for\r\nscience fiction, fantasy, and horror books. Present your EFF Member Card\r\nand get a 10% discount on in-store purchases. Borderlands Cafe also\r\noffers occasional EFF Member specials so be sure to stop by for some\r\nreading time and a treat! http://www.borderlands-books.com\r\n\r\n-Magnatune: Get an $8 gift card from Magnatune, the music download\r\nservice that isn't evil. All the music is DRM free and licensed under\r\nCreative Commons. Musicians get 50%, you get to choose the price you\r\npay, and you're encouraged to share your purchased music with 3 friends.\r\nGo to http://magnatune.com and use the gift code: 111801248707\r\n\r\n-No Starch Press: Get a 30% discount on geektastic books that entertain\r\nand/or instruct by using the code EFFMEMBER at http://www.nostarch.com.\r\n\r\n-Take Control Ebooks: Get a 30% off by following this EFF member portal.\r\nhttp://www.takecontrolbooks.com/?pt=EFF&cp=CPN80131EFF\r\n\r\n-- \r\nAaron Jue\r\nEFF Senior Membership Advocate\r\nmembership@eff.org\r\n\r\n"}},"desiredParts":[{"id":"1","encoding":"7BIT","mimetype":"text/plain"}],"result":{"id":"addb4e92bde89a7898ea31b9bbc866b35eb1b5e150bc69a47ed239b1679a7c1a","to":[{"name":"","email":"christine@spang.cc"}],"cc":[],"bcc":[],"from":[{"name":"Member Services","email":"membership@eff.org"}],"replyTo":[{"name":"","email":"membership@eff.org"}],"accountId":"test-account-id","body":"<pre class=\"nylas-plaintext\">Thank you for being a member of the Electronic Frontier Foundation! Your\r\nEFF membership lasts for 12 months and you have the opportunity to\r\nselect a free gift every time you renew! If you are a monthly donor,\r\nyour membership lasts as long as you like, and you are eligible for a\r\nmember gift every 12 months. Contributions are tax deductible as allowed\r\nby law. EFF is a U.S. 501(c)(3) organization, and our federal tax ID\r\nnumber is 04-3091431.\r\n\r\nYour contribution makes a significant difference in our ability to\r\ndefend your rights in the digital world whether that means standing up\r\nfor users in the courts, educating the public about dangerous laws, or\r\ncreating privacy-enhancing technologies. We are pleased to offer you a\r\nfew modest perks as a token of our thanks. This is a one-time email\r\nnotice and EFF will never share your information with partnering or\r\nsupporting organizations. Contact us at membership@eff.org if you have\r\nany questions!\r\n\r\nEFF MEMBER BENEFITS:\r\n\r\n-EFF Online Rights bumper sticker (via print mail).\r\n\r\n-EFF Member Card (via print mail).\r\n\r\n-Digital Badges: Show your support on your blog, website, or in an HTML\r\nemail signature.\r\nhttps://www.eff.org/files/2016/11/01/2017mb.png\r\n\r\n-Discounts on Events: Receive discounts on General Admission to EFF\r\nevents! Choose the member price when purchasing tickets or show your EFF\r\nMember card at the door. Watch for specific details in event invitations.\r\n\r\n-Speakeasy Invitations: Get notified about informal members-only meetups\r\nand drink ups with EFF lawyers, activists, and technologists in your area!\r\n\r\n-EFF Online Shop Discount: Get 10% off purchases (Gift Memberships\r\nexcluded) at EFF's online store by using the discount code ALIQUID16 at\r\nhttps://www.eff.org/shop.\r\n\r\nPARTNER DISCOUNTS FOR EFF MEMBERS:\r\n\r\n-LeanPub: Get a copy of Uncensored, an ever expanding collection of\r\nessays on Internet freedom from many of its original innovators. Follow\r\nthis promo url: http://leanpub.com/uncensored/c/effdonor.\r\n\r\n-Borderlands Books and Cafe: Borderlands is San Francisco's home for\r\nscience fiction, fantasy, and horror books. Present your EFF Member Card\r\nand get a 10% discount on in-store purchases. Borderlands Cafe also\r\noffers occasional EFF Member specials so be sure to stop by for some\r\nreading time and a treat! http://www.borderlands-books.com\r\n\r\n-Magnatune: Get an $8 gift card from Magnatune, the music download\r\nservice that isn't evil. All the music is DRM free and licensed under\r\nCreative Commons. Musicians get 50%, you get to choose the price you\r\npay, and you're encouraged to share your purchased music with 3 friends.\r\nGo to http://magnatune.com and use the gift code: 111801248707\r\n\r\n-No Starch Press: Get a 30% discount on geektastic books that entertain\r\nand/or instruct by using the code EFFMEMBER at http://www.nostarch.com.\r\n\r\n-Take Control Ebooks: Get a 30% off by following this EFF member portal.\r\nhttp://www.takecontrolbooks.com/?pt=EFF爀- \r\nAaron Jue\r\nEFF Senior Membership Advocate\r\nmembership@eff.org\r\n\r\n</pre>","snippet":"Thank you for being a member of the Electronic Frontier Foundation! Your EFF membership lasts for 12","unread":false,"starred":false,"date":"2016-12-01T01:34:44.000Z","folderImapUID":348040,"folderId":"test-folder-id","folder":{"id":"test-folder-id","account_id":"test-account-id","object":"folder","name":null,"display_name":"Test Folder"},"labels":[],"headers":{"delivered-to":["christine@spang.cc"],"received":["by 10.140.100.181 with SMTP id s50csp492441qge; Wed, 30 Nov 2016 17:34:44 -0800 (PST)","from mail2.eff.org (mail2.eff.org. [173.239.79.204]) by mx.google.com with ESMTPS id c198si18454640ywb.136.2016.11.30.17.34.44 for <christine@spang.cc> (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 30 Nov 2016 17:34:44 -0800 (PST)","from static-69.50.232.52.nephosdns.com ([69.50.232.52]:57896 helo=web5.eff.org) by mail2.eff.org with esmtp (Exim 4.80) (envelope-from <www-data@web5.eff.org>) id 1cCGGo-000366-QC for christine@spang.cc; Wed, 30 Nov 2016 17:34:42 -0800","by web5.eff.org (Postfix, from userid 33) id BFBE132AD8C; Wed, 30 Nov 2016 17:34:42 -0800 (PST)"],"x-received":["by 10.129.120.215 with SMTP id t206mr41825274ywc.39.1480556084610; Wed, 30 Nov 2016 17:34:44 -0800 (PST)"],"return-path":["<www-data@web5.eff.org>"],"received-spf":["pass (google.com: best guess record for domain of www-data@web5.eff.org designates 173.239.79.204 as permitted sender) client-ip=173.239.79.204;","skipped for local relay"],"authentication-results":["mx.google.com; dkim=pass header.i=@eff.org; spf=pass (google.com: best guess record for domain of www-data@web5.eff.org designates 173.239.79.204 as permitted sender) smtp.mailfrom=www-data@web5.eff.org; dmarc=pass (p=NONE dis=NONE) header.from=eff.org"],"dkim-signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=eff.org; s=mail2; h=Date:Message-Id:Sender:Reply-To:From:Subject:To; bh=85sXKrmP+EL3X9i986SKLxXpb0v60xG0c09b/uRaP10=; b=IByfHFGQGSbxCZfsWU5gd3ek92bd4yhEReZ8qDGPo/CWDCeUO3QnB6yY3aMpuJdD9TUUUKM6rcmfpz4zTmCtwkakMW/uIay2CBXUWuAsowRwUtofpIDmn4aDOhkMUHvyMZe9cZhpgWr7EC1JqEI+3J/kvhR/HTgi7r0dVnz7FBk=;"],"to":["christine@spang.cc"],"subject":["EFF Membership Benefits"],"from":["Member Services <membership@eff.org>"],"reply-to":["membership@eff.org"],"sender":["membership@eff.org"],"message-id":["<20161201013442.BFBE132AD8C@web5.eff.org>"],"date":["Wed, 30 Nov 2016 17:34:42 -0800 (PST)"],"x-gm-thrid":"1552475576878158784","x-gm-msgid":"1552475576878158784","x-gm-labels":["\\Inbox"]},"headerMessageId":"<20161201013442.BFBE132AD8C@web5.eff.org>","subject":"EFF Membership Benefits","folderImapXGMLabels":"[\"\\\\Inbox\"]"}}