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 2318F431FC3 for ; Tue, 25 Dec 2012 19:49:03 -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 rU5YGJNLa-m7 for ; Tue, 25 Dec 2012 19:49:00 -0800 (PST) Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU [18.7.68.35]) by olra.theworths.org (Postfix) with ESMTP id E8F1F431FB6 for ; Tue, 25 Dec 2012 19:48:58 -0800 (PST) X-AuditID: 12074423-b7ef96d000000725-d7-50da73aaa6d1 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP id 35.24.01829.AA37AD05; Tue, 25 Dec 2012 22:48:58 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id qBQ3mvbZ031278; Tue, 25 Dec 2012 22:48:57 -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 qBQ3mrna013183 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Tue, 25 Dec 2012 22:48:55 -0500 (EST) Received: from amthrax by drake.dyndns.org with local (Exim 4.77) (envelope-from ) id 1Tnhz8-0002z0-RX; Tue, 25 Dec 2012 22:48:50 -0500 From: Austin Clements To: notmuch@notmuchmail.org Subject: [PATCH v2 3/5] dump: Disallow \n in message IDs Date: Tue, 25 Dec 2012 22:48:41 -0500 Message-Id: <1356493723-11085-4-git-send-email-amdragon@mit.edu> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1356493723-11085-1-git-send-email-amdragon@mit.edu> References: <1356493723-11085-1-git-send-email-amdragon@mit.edu> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrLIsWRmVeSWpSXmKPExsUixG6noruq+FaAQetMMYsbrd2MFk3TnS1W z+WxuH5zJrMDi8fOWXfZPW7df83u8WzVLWaPLYfeMwewRHHZpKTmZJalFunbJXBlXJnfz1qw XLBi1/MrzA2Mt3i7GDk5JARMJH7en8cMYYtJXLi3ng3EFhLYxyix+bdhFyMXkL2BUeLU9HZG COcik8SCE73MEFVzGSWetSaC2GwCGhLb9i9nBLFFBKQldt6dzQpiMwvkSTx8tJUdxBYWsJBo nv4PbAOLgKrEvZdHwWxeAQeJbec/sENcoSjR/WwCUJyDg1PAUWLngzqIVQ4SEx+eZ5rAyL+A kWEVo2xKbpVubmJmTnFqsm5xcmJeXmqRrplebmaJXmpK6SZGcKi5KO9g/HNQ6RCjAAejEg8v x6+bAUKsiWXFlbmHGCU5mJREebcX3AoQ4kvKT6nMSCzOiC8qzUktPsQowcGsJMLr/BGonDcl sbIqtSgfJiXNwaIkznst5aa/kEB6YklqdmpqQWoRTFaGg0NJglcHGFNCgkWp6akVaZk5JQhp Jg5OkOE8QMPFQGp4iwsSc4sz0yHypxgVpcR5pUESAiCJjNI8uF5YKnjFKA70ijDvryKgKh5g GoHrfgU0mAlocCzfDZDBJYkIKakGRuYs9mbDx1+7b/dN5FynedBE7g8zy3uP5ix2Lq6Sb0zn XWUfX7C/MK1MVUnxjcXcvjN5DO6+c9vOeGWIrNjJYPg72dVoxV+bygQZIe9NvxWu/ahb9LWm x9pjfs9LwWUzZQLYJKfW9rxmfLw36cD6s/VSqhXzM8r4/ibMrV0nbLlmy6p/K3njlViKMxIN tZiLihMB5LZFd+ACAAA= 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: Wed, 26 Dec 2012 03:49:04 -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 | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) 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..8b7748e 100644 --- a/test/random-corpus.c +++ b/test/random-corpus.c @@ -96,7 +96,9 @@ random_utf8_string (void *ctx, size_t char_count) buf = talloc_realloc (ctx, buf, gchar, buf_size); } - randomchar = random_unichar (); + do { + randomchar = random_unichar (); + } while (randomchar == '\n'); written = g_unichar_to_utf8 (randomchar, buf + offset); -- 1.7.10.4