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 9B673431FC4 for ; Mon, 24 Dec 2012 21:58:17 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 fuKyTdpzY0gV for ; Mon, 24 Dec 2012 21:58:14 -0800 (PST) Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU [18.9.25.12]) by olra.theworths.org (Postfix) with ESMTP id 34CB5431FB6 for ; Mon, 24 Dec 2012 21:58:14 -0800 (PST) X-AuditID: 1209190c-b7fa86d000001d37-2d-50d940759f1a Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP id 6B.7C.07479.57049D05; Tue, 25 Dec 2012 00:58:13 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id qBP5wCKE008903; Tue, 25 Dec 2012 00:58:12 -0500 Received: from drake.dyndns.org (c-76-21-105-205.hsd1.ca.comcast.net [76.21.105.205]) (authenticated bits=0) (User authenticated as amdragon@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qBP5w7ps011706 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Tue, 25 Dec 2012 00:58:09 -0500 (EST) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1TnNWg-0001Xs-NZ; Tue, 25 Dec 2012 00:58:06 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH 3/5] dump: Disallow \n in message IDs Date: Tue, 25 Dec 2012 00:57:54 -0500 Message-Id: <1356415076-5692-4-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1356415076-5692-1-git-send-email-amdragon@mit.edu> References: <1356415076-5692-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrAIsWRmVeSWpSXmKPExsUixG6nrlvqcDPAYPlGXosbrd2MFk3TnS1W z+WxuH5zJrMDi8fOWXfZPW7df83u8WzVLWaPLYfeMwewRHHZpKTmZJalFunbJXBlXLp7hLXg oEBFx8Fu9gbGTt4uRk4OCQETiTeHrzNB2GISF+6tZ+ti5OIQEtjHKPGq8QWUs4FRYvO6t1DO RSaJJUffs0A4cxklGpb8AOtnE9CQ2LZ/OSOILSIgLbHz7mxWEJtZIE/i4aOt7CC2sICpxIQd B5lBbBYBVYlnNz+A1fMK2EvM7H/NCHGHokT3swlsIDangIPE3D8rWUBsIaCar3M3s0xg5F/A yLCKUTYlt0o3NzEzpzg1Wbc4OTEvL7VI11AvN7NELzWldBMjKOA4JXl2ML45qHSIUYCDUYmH t2DyjQAh1sSy4srcQ4ySHExKoryv7W4GCPEl5adUZiQWZ8QXleakFh9ilOBgVhLhNeEByvGm JFZWpRblw6SkOViUxHkvp9z0FxJITyxJzU5NLUgtgsnKcHAoSfD+ARkqWJSanlqRlplTgpBm 4uAEGc4DNFzSHmR4cUFibnFmOkT+FKOilDjvT5BmAZBERmkeXC8sIbxiFAd6RZhXCKSdB5hM 4LpfAQ1mAhocy3cDZHBJIkJKqoHRgZkne96catGvJ3eLMLDmNS1bMVlIrf/8b77iw23md59u stgao6USfGjn8dQVB9IE35vVKv0om3qTy4r5syzfK6sDc59Nmq9xe2XPjpjjUyet7LP8MO0a y86l12cFqt5r0nr56vh5Zu0SkW5vec9XQcxrTHm6bDeLSC5wLQ1i7jzy9Oeba9N+KbEUZyQa ajEXFScCANFaIvbjAgAA 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: Tue, 25 Dec 2012 05:58:18 -0000 When we switch to using regular Xapian queries in the dump format, \n will cause problems, so we disallow it. Specially, while Xapian can quote and parse queries containing \n without difficultly, quoted queries containing \n still span multiple lines, which breaks the line-orientedness of the dump format. Strictly speaking, we could still round-trip these, but it would significantly complicate restore as well as scripts that deal with tag dumps. This complexity would come at absolutely no benefit: because of the RFC 2822 unfolding rules, no amount of standards negligence can produce a message with a message ID containing a line break (not even Outlook can do it!). Hence, we simply disallow it. --- notmuch-dump.c | 9 +++++++++ test/random-corpus.c | 2 ++ 2 files changed, 11 insertions(+) diff --git a/notmuch-dump.c b/notmuch-dump.c index d2dad40..29d79da 100644 --- a/notmuch-dump.c +++ b/notmuch-dump.c @@ -132,6 +132,15 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[]) if (output_format == DUMP_FORMAT_SUP) { fputs (")\n", output); } else { + if (strchr (message_id, '\n')) { + /* This will produce a line break in the output, which + * would be difficult to handle in tools. However, + * it's also impossible to produce an email containing + * a line break in a message ID because of unfolding, + * so we can safely disallow it. */ + fprintf (stderr, "Error: cannot dump message id containing line break: %s\n", message_id); + return 1; + } if (hex_encode (notmuch, message_id, &buffer, &buffer_size) != HEX_SUCCESS) { fprintf (stderr, "Error: failed to hex-encode msg-id %s\n", diff --git a/test/random-corpus.c b/test/random-corpus.c index f354d4b..d0e3e8f 100644 --- a/test/random-corpus.c +++ b/test/random-corpus.c @@ -97,6 +97,8 @@ random_utf8_string (void *ctx, size_t char_count) } randomchar = random_unichar (); + if (randomchar == '\n') + randomchar = 'x'; written = g_unichar_to_utf8 (randomchar, buf + offset); -- 1.7.10.4