--- /dev/null
+Return-Path: <m.walters@qmul.ac.uk>\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 0018A431FAF\r
+ for <notmuch@notmuchmail.org>; Sun, 23 Dec 2012 00:19:30 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+ tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+ NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 MlAfxwpVKgnL for <notmuch@notmuchmail.org>;\r
+ Sun, 23 Dec 2012 00:19:28 -0800 (PST)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 66E6E431FAE\r
+ for <notmuch@notmuchmail.org>; Sun, 23 Dec 2012 00:19:28 -0800 (PST)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+ by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1TmgmG-0005A0-3l; Sun, 23 Dec 2012 08:19:22 +0000\r
+Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
+ by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+ (envelope-from <m.walters@qmul.ac.uk>)\r
+ id 1TmgmF-0004BE-LS; Sun, 23 Dec 2012 08:19:19 +0000\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: david@tethera.net, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] simplify unhex_and_quote\r
+In-Reply-To: <1356231570-28232-1-git-send-email-david@tethera.net>\r
+References: <87txrdhd7g.fsf@oiva.home.nikula.org>\r
+ <1356231570-28232-1-git-send-email-david@tethera.net>\r
+User-Agent: Notmuch/0.14+236~g1d0044f (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sun, 23 Dec 2012 08:19:20 +0000\r
+Message-ID: <87a9t5p4dz.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 93.97.24.31\r
+X-QM-SPAM-Info: Sender has good ham record. :)\r
+X-QM-Body-MD5: daa53310a90217d87a28cd2cc186fe1a (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.8\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+ determine if it is\r
+ spam. We require at least 5.0 points to mark a message as spam.\r
+ This message scored -1.8 points.\r
+ Summary of the scoring: \r
+ * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+ * medium trust\r
+ * [138.37.6.40 listed in list.dnswl.org]\r
+ * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+ provider * (markwalters1009[at]gmail.com)\r
+ * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
+ * domain\r
+ * 0.5 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\r
+Cc: David Bremner <bremner@unb.ca>\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: Sun, 23 Dec 2012 08:19:31 -0000\r
+\r
+\r
+On Sun, 23 Dec 2012, david@tethera.net wrote:\r
+> From: David Bremner <bremner@unb.ca>\r
+>\r
+> the overgeneral definition of a prefix can be replaced by lower case\r
+> alphabetic, and still work fine with current notmuch query syntax.\r
+>\r
+> token_len++ is moved to the end, and we restore the delimiter just so\r
+> we can leave the string as as we found it.\r
+> ---\r
+>\r
+> As always, Jani has a keen eye for muddle. Except he's wrong about \r
+> tok_len - prefix_len, and Mark and I are right. Hopefully ;).\r
+>\r
+> Restoring the delimiter at the end might be pointless (since the rest\r
+> of the input line is modified), but it is one less surprise for somebody \r
+> repurposing the function.\r
+\r
+I am now worried about side bit of Xapian syntax, in particular, what\r
+about brackets. I think we could have\r
+\r
+(tag:inbox or tag:tag%20with%20spaces) and <something>\r
+\r
+In which case the first token is (tag:inbox which does not\r
+match. Additionally the third token is tag:tag%20with%20spaces) which\r
+presumably gets quoted to tag:"tag with spaces)" and I am guessing\r
+Xapian treats this differently than with bracket after the quote.\r
+\r
+Finally, I don't know if a query can contain a : without being a prefix\r
+query. If it can that could end up being misquoted.\r
+\r
+One possible way round the first problem might be to require the Xapian\r
+syntax to be space separated from the rest but that does mean we are\r
+diverging from the command line syntax.\r
+\r
+(I am not very familiar with Xapian syntax nor with quite where this\r
+function is used so I may be worrying about nothing)\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+\r
+\r
+\r
+>\r
+> Patches 5 and 6 can be ignored now.\r
+> tag-util.c | 12 ++++++++----\r
+> 1 file changed, 8 insertions(+), 4 deletions(-)\r
+>\r
+> diff --git a/tag-util.c b/tag-util.c\r
+> index b0a846b..ee28512 100644\r
+> --- a/tag-util.c\r
+> +++ b/tag-util.c\r
+> @@ -78,11 +78,13 @@ unhex_and_quote (void *ctx, char *encoded, const char *line_for_error,\r
+> size_t prefix_len;\r
+> char delim = *(tok + tok_len);\r
+> \r
+> - *(tok + tok_len++) = '\0';\r
+> + *(tok + tok_len) = '\0';\r
+> \r
+> - prefix_len = hex_invariant (tok, tok_len);\r
+> + /* The following matches a superset of prefixes currently\r
+> + * used by notmuch */\r
+> + prefix_len = strspn (tok, "abcdefghijklmnopqrstuvwxyz");\r
+> \r
+> - if ((strcmp (tok, "*") == 0) || prefix_len >= tok_len - 1) {\r
+> + if ((strcmp (tok, "*") == 0) || prefix_len == tok_len) {\r
+> \r
+> /* pass some things through without quoting or decoding.\r
+> * Note for '*' this is mandatory.\r
+> @@ -98,7 +100,7 @@ unhex_and_quote (void *ctx, char *encoded, const char *line_for_error,\r
+> \r
+> } else {\r
+> /* potential prefix: one for ':', then something after */\r
+> - if ((tok_len - prefix_len > 2) && *(tok + prefix_len) == ':') {\r
+> + if ((tok_len - prefix_len >= 2) && *(tok + prefix_len) == ':') {\r
+> if (! (*query_string = talloc_strndup_append (*query_string,\r
+> tok,\r
+> prefix_len + 1))) {\r
+> @@ -129,6 +131,8 @@ unhex_and_quote (void *ctx, char *encoded, const char *line_for_error,\r
+> goto DONE;\r
+> }\r
+> }\r
+> + /* restore the string and skip delimiter */\r
+> + *(tok + tok_len++) = delim;\r
+> }\r
+> \r
+> DONE:\r
+> -- \r
+> 1.7.10.4\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r