--- /dev/null
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 2318F431FC3\r
+ for <notmuch@notmuchmail.org>; Tue, 25 Dec 2012 19:49:03 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id rU5YGJNLa-m7 for <notmuch@notmuchmail.org>;\r
+ Tue, 25 Dec 2012 19:49:00 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU\r
+ [18.7.68.35])\r
+ by olra.theworths.org (Postfix) with ESMTP id E8F1F431FB6\r
+ for <notmuch@notmuchmail.org>; Tue, 25 Dec 2012 19:48:58 -0800 (PST)\r
+X-AuditID: 12074423-b7ef96d000000725-d7-50da73aaa6d1\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+ by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 35.24.01829.AA37AD05; Tue, 25 Dec 2012 22:48:58 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id qBQ3mvbZ031278; \r
+ Tue, 25 Dec 2012 22:48:57 -0500\r
+Received: from drake.dyndns.org (c-76-21-105-205.hsd1.ca.comcast.net\r
+ [76.21.105.205]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qBQ3mrna013183\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Tue, 25 Dec 2012 22:48:55 -0500 (EST)\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1Tnhz8-0002z0-RX; Tue, 25 Dec 2012 22:48:50 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2 3/5] dump: Disallow \n in message IDs\r
+Date: Tue, 25 Dec 2012 22:48:41 -0500\r
+Message-Id: <1356493723-11085-4-git-send-email-amdragon@mit.edu>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1356493723-11085-1-git-send-email-amdragon@mit.edu>\r
+References: <1356493723-11085-1-git-send-email-amdragon@mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFjrLIsWRmVeSWpSXmKPExsUixG6noruq+FaAQetMMYsbrd2MFk3TnS1W\r
+ z+WxuH5zJrMDi8fOWXfZPW7df83u8WzVLWaPLYfeMwewRHHZpKTmZJalFunbJXBlXJnfz1qw\r
+ XLBi1/MrzA2Mt3i7GDk5JARMJH7en8cMYYtJXLi3ng3EFhLYxyix+bdhFyMXkL2BUeLU9HZG\r
+ COcik8SCE73MEFVzGSWetSaC2GwCGhLb9i9nBLFFBKQldt6dzQpiMwvkSTx8tJUdxBYWsJBo\r
+ nv4PbAOLgKrEvZdHwWxeAQeJbec/sENcoSjR/WwCUJyDg1PAUWLngzqIVQ4SEx+eZ5rAyL+A\r
+ kWEVo2xKbpVubmJmTnFqsm5xcmJeXmqRrplebmaJXmpK6SZGcKi5KO9g/HNQ6RCjAAejEg8v\r
+ x6+bAUKsiWXFlbmHGCU5mJREebcX3AoQ4kvKT6nMSCzOiC8qzUktPsQowcGsJMLr/BGonDcl\r
+ sbIqtSgfJiXNwaIkznst5aa/kEB6YklqdmpqQWoRTFaGg0NJglcHGFNCgkWp6akVaZk5JQhp\r
+ Jg5OkOE8QMPFQGp4iwsSc4sz0yHypxgVpcR5pUESAiCJjNI8uF5YKnjFKA70ijDvryKgKh5g\r
+ GoHrfgU0mAlocCzfDZDBJYkIKakGRuYs9mbDx1+7b/dN5FynedBE7g8zy3uP5ix2Lq6Sb0zn\r
+ XWUfX7C/MK1MVUnxjcXcvjN5DO6+c9vOeGWIrNjJYPg72dVoxV+bygQZIe9NvxWu/ahb9LWm\r
+ x9pjfs9LwWUzZQLYJKfW9rxmfLw36cD6s/VSqhXzM8r4/ibMrV0nbLlmy6p/K3njlViKMxIN\r
+ tZiLihMB5LZFd+ACAAA=\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 26 Dec 2012 03:49:04 -0000\r
+\r
+When we switch to using regular Xapian queries in the dump format, \n\r
+will cause problems, so we disallow it. Specially, while Xapian can\r
+quote and parse queries containing \n without difficultly, quoted\r
+queries containing \n still span multiple lines, which breaks the\r
+line-orientedness of the dump format. Strictly speaking, we could\r
+still round-trip these, but it would significantly complicate restore\r
+as well as scripts that deal with tag dumps. This complexity would\r
+come at absolutely no benefit: because of the RFC 2822 unfolding\r
+rules, no amount of standards negligence can produce a message with a\r
+message ID containing a line break (not even Outlook can do it!).\r
+\r
+Hence, we simply disallow it.\r
+---\r
+ notmuch-dump.c | 9 +++++++++\r
+ test/random-corpus.c | 4 +++-\r
+ 2 files changed, 12 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/notmuch-dump.c b/notmuch-dump.c\r
+index d2dad40..29d79da 100644\r
+--- a/notmuch-dump.c\r
++++ b/notmuch-dump.c\r
+@@ -132,6 +132,15 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])\r
+ if (output_format == DUMP_FORMAT_SUP) {\r
+ fputs (")\n", output);\r
+ } else {\r
++ if (strchr (message_id, '\n')) {\r
++ /* This will produce a line break in the output, which\r
++ * would be difficult to handle in tools. However,\r
++ * it's also impossible to produce an email containing\r
++ * a line break in a message ID because of unfolding,\r
++ * so we can safely disallow it. */\r
++ fprintf (stderr, "Error: cannot dump message id containing line break: %s\n", message_id);\r
++ return 1;\r
++ }\r
+ if (hex_encode (notmuch, message_id,\r
+ &buffer, &buffer_size) != HEX_SUCCESS) {\r
+ fprintf (stderr, "Error: failed to hex-encode msg-id %s\n",\r
+diff --git a/test/random-corpus.c b/test/random-corpus.c\r
+index f354d4b..8b7748e 100644\r
+--- a/test/random-corpus.c\r
++++ b/test/random-corpus.c\r
+@@ -96,7 +96,9 @@ random_utf8_string (void *ctx, size_t char_count)\r
+ buf = talloc_realloc (ctx, buf, gchar, buf_size);\r
+ }\r
+ \r
+- randomchar = random_unichar ();\r
++ do {\r
++ randomchar = random_unichar ();\r
++ } while (randomchar == '\n');\r
+ \r
+ written = g_unichar_to_utf8 (randomchar, buf + offset);\r
+ \r
+-- \r
+1.7.10.4\r
+\r