From 2c0d370adec4aa2662c887759bfac3daf17f2f84 Mon Sep 17 00:00:00 2001 From: John Lenz Date: Thu, 25 Jul 2013 21:36:11 +1900 Subject: [PATCH] Re: cli: add --include-html option to notmuch show --- 5d/aab456a07fbbe93e2f1ccd215c622593fd70f2 | 173 ++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 5d/aab456a07fbbe93e2f1ccd215c622593fd70f2 diff --git a/5d/aab456a07fbbe93e2f1ccd215c622593fd70f2 b/5d/aab456a07fbbe93e2f1ccd215c622593fd70f2 new file mode 100644 index 000000000..216f8ccd7 --- /dev/null +++ b/5d/aab456a07fbbe93e2f1ccd215c622593fd70f2 @@ -0,0 +1,173 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 9B905431FBC + for ; Wed, 24 Jul 2013 19:36:17 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id c3Rwa-DJySoA for ; + Wed, 24 Jul 2013 19:36:13 -0700 (PDT) +Received: from smtp.rcn.com (smtp.rcn.com [69.168.97.78]) + by olra.theworths.org (Postfix) with ESMTP id 7D74E431FB6 + for ; Wed, 24 Jul 2013 19:36:13 -0700 (PDT) +X_CMAE_Category: 0,0 Undefined,Undefined +X-CNFS-Analysis: v=2.1 cv=G7glTbU5 c=1 sm=0 tr=0 + a=C2bPeGdon5f+QfTtoGFpIg==:117 a=C2bPeGdon5f+QfTtoGFpIg==:17 + a=K-v-2zaBAAAA:8 a=gxDP-SbUGcMA:10 a=97V-WqMTq8EA:10 + a=IkcTkHD0fZMA:10 a=3wHbS4G-AAAA:8 a=Qdy8_LB6nwUA:10 + a=A1X0JdhQAAAA:8 a=Nn0Esa4SKUPhQueadGoA:9 a=0z3RHW59VqRJKvoH:21 + a=LRJ8JICpaW-XGMMz:21 a=QEXdDO2ut3YA:10 a=Y6qChIQXU1wA:10 +X-CM-Score: 0 +X-Scanned-by: Cloudmark Authority Engine +Authentication-Results: smtp01.rcn.cmh.synacor.com + header.from=wuzzeb@wuzzeb.org; sender-id=pass +Authentication-Results: smtp01.rcn.cmh.synacor.com + smtp.mail=wuzzeb@wuzzeb.org; spf=pass; sender-id=pass +Received-SPF: pass (smtp01.rcn.cmh.synacor.com: domain wuzzeb.org designates + 205.178.10.182 as permitted sender) +Received: from [205.178.10.182] ([205.178.10.182:44046] helo=wuzzeb.org) + by smtp.rcn.com (envelope-from ) + (ecelerity 2.2.3.49 r(42060/42061)) with ESMTP + id 12/15-21927-C1F80F15; Wed, 24 Jul 2013 22:36:12 -0400 +Received: from wuzzeb by wuzzeb.org with local (Exim 4.80.1) + (envelope-from ) + id 1V2BPX-0007vw-Op; Wed, 24 Jul 2013 21:36:11 -0500 +From: =?utf-8?Q?John_Lenz?= +To: =?utf-8?Q?Tomi_Ollila?= , +Subject: Re: cli: add --include-html option to notmuch show +Message-ID: +In-reply-to: +References: + +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Sender: +Date: Wed, 24 Jul 2013 21:36:11 -0500 +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Thu, 25 Jul 2013 02:36:17 -0000 + +On Sun Jul 21 15:23 -0500 2013, Tomi Ollila wrote: +> On Tue, Jul 02 2013, John Lenz wrote: +> +> > For my client, the largest bottleneck for displaying large threads is +> > exporting each html part individually since by default notmuch will not +> > show the json parts. For large threads there can be quite a few parts and +> > each must be exported and decoded one by one. Also, I then have to deal +> > with all the crazy charsets which I can do through a library but is a +> > pain. +> +> This looks like a useful option. I just wonder what effect does different +> charsets do to the output (is text/html content output verbatim (with just +> json/sexp escaping of '"' -characters). +> +> If you added test(s) showing what happens with different charsets +> (like one message having 3 text/html parts, one us-ascii, one iso-8859-1 +> and one utf-8) that would make things clearer and (also) protect us from +> regressions. +> + + +Here is a test I wrote. I tried to follow the other tests in formatting. +Let me know if you want this as a single patch combined with the code +to enable the option, I can resend it. + + + +#!/usr/bin/env bash +test_description="include html parts when showing message" +. ./test-lib.sh + +cat < ${MAIL_DIR}/msg +From: A +To: B +Subject: html message +Date: Sat, 01 January 2000 00:00:00 +0000 +Message-ID: +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="==-==" + +--==-== +Content-Type: text/html; charset=UTF-8 + +EOF +# The Unicode fraction symbol 1/2 is U+00BD and is encoded +# in UTF-8 as two bytes: octal 302 275 +echo $'

0.5 equals \302\275

' >> ${MAIL_DIR}/msg +cat <> ${MAIL_DIR}/msg + +--==-== +Content-Type: text/html; charset=ISO-8859-1 + +EOF +# The ISO-8859-1 encoding of U+00BD is a single byte: octal 275 +echo $'

0.5 equals \275

' >> ${MAIL_DIR}/msg +cat <> ${MAIL_DIR}/msg + +--==-== +Content-Type: text/plain; charset=UTF-8 + +0.5 equals 1/2 + +--==-==-- +EOF + +notmuch new > /dev/null + + +cat < EXPECTED.head +[[[{"id": "htmlmessage", "match":true, "excluded": false, "date_relative":"2000-01-01", + "timestamp": 946684800, + "filename": "${MAIL_DIR}/msg", + "tags": ["inbox", "unread"], + "headers": { "Date": "Sat, 01 Jan 2000 00:00:00 +0000", "From": "A ", + "Subject": "html message", "To": "B "}, + "body": [{ + "content-type": "multipart/alternative", "id": 1, +EOF + +cat EXPECTED.head > EXPECTED.nohtml +cat <> EXPECTED.nohtml +"content": [ + { "id": 2, "content-charset": "UTF-8", "content-length": 21, "content-type": "text/html"}, + { "id": 3, "content-charset": "ISO-8859-1", "content-length": 20, "content-type": "text/html"}, + { "id": 4, "content-type": "text/plain", "content": "0.5 equals 1/2\\n"} +]}]},[]]]] +EOF + +# Both the UTF-8 and ISO-8859-1 part should have U+00BD +cat EXPECTED.head > EXPECTED.withhtml +cat <> EXPECTED.withhtml +"content": [ + { "id": 2, "content-type": "text/html", "content": "

0.5 equals \\u00bd

\\n"}, + { "id": 3, "content-type": "text/html", "content": "

0.5 equals \\u00bd

\\n"}, + { "id": 4, "content-type": "text/plain", "content": "0.5 equals 1/2\\n"} +]}]},[]]]] +EOF + +test_begin_subtest "html parts excluded by default" +notmuch show --format=json id:htmlmessage >OUTPUT +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.nohtml)" + +test_begin_subtest "html parts included" +notmuch show --format=json --include-html id:htmlmessage > OUTPUT +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED.withhtml)" + +test_done -- 2.26.2