1 Return-Path: <m.walters@qmul.ac.uk>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 05988431FBC
\r
6 for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 09:54:24 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5
\r
12 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,
\r
13 NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id gud32u2idbBc for <notmuch@notmuchmail.org>;
\r
17 Sat, 15 Dec 2012 09:54:21 -0800 (PST)
\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id BA7BE431FB6
\r
22 for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 09:54:20 -0800 (PST)
\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])
\r
24 by mail2.qmul.ac.uk with esmtp (Exim 4.71)
\r
25 (envelope-from <m.walters@qmul.ac.uk>)
\r
26 id 1TjvwH-0005eT-00; Sat, 15 Dec 2012 17:54:19 +0000
\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)
\r
28 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)
\r
29 (envelope-from <m.walters@qmul.ac.uk>)
\r
30 id 1TjvwG-00006z-JJ; Sat, 15 Dec 2012 17:54:16 +0000
\r
31 From: Mark Walters <markwalters1009@gmail.com>
\r
32 To: david@tethera.net, notmuch@notmuchmail.org
\r
33 Subject: Re: [Patch v7 06/14] notmuch-restore: move query handling for batch
\r
35 In-Reply-To: <1355492062-7546-7-git-send-email-david@tethera.net>
\r
36 References: <1355492062-7546-1-git-send-email-david@tethera.net>
\r
37 <1355492062-7546-7-git-send-email-david@tethera.net>
\r
38 User-Agent: Notmuch/0.14+155~g7edfdc3 (http://notmuchmail.org) Emacs/23.4.1
\r
39 (x86_64-pc-linux-gnu)
\r
40 Date: Sat, 15 Dec 2012 17:54:18 +0000
\r
41 Message-ID: <87wqwj8alx.fsf@qmul.ac.uk>
\r
43 Content-Type: text/plain; charset=us-ascii
\r
44 X-Sender-Host-Address: 93.97.24.31
\r
45 X-QM-SPAM-Info: Sender has good ham record. :)
\r
46 X-QM-Body-MD5: 8037058b0ecd4dac9122cab8000d295f (of first 20000 bytes)
\r
47 X-SpamAssassin-Score: -1.8
\r
48 X-SpamAssassin-SpamBar: -
\r
49 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
51 spam. We require at least 5.0 points to mark a message as spam.
\r
52 This message scored -1.8 points.
\r
53 Summary of the scoring:
\r
54 * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,
\r
56 * [138.37.6.40 listed in list.dnswl.org]
\r
57 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
58 provider * (markwalters1009[at]gmail.com)
\r
59 * 0.5 AWL AWL: From: address is in the auto white-list
\r
60 X-QM-Scan-Virus: ClamAV says the message is clean
\r
61 Cc: David Bremner <bremner@debian.org>
\r
62 X-BeenThere: notmuch@notmuchmail.org
\r
63 X-Mailman-Version: 2.1.13
\r
65 List-Id: "Use and development of the notmuch mail system."
\r
66 <notmuch.notmuchmail.org>
\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
70 List-Post: <mailto:notmuch@notmuchmail.org>
\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
73 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
74 X-List-Received-Date: Sat, 15 Dec 2012 17:54:33 -0000
\r
76 On Fri, 14 Dec 2012, david@tethera.net wrote:
\r
77 > From: David Bremner <bremner@debian.org>
\r
79 > We are able to detect more errors by looking at the string before it
\r
80 > is hex-decoded. We also need this to avoid the query quoting for more
\r
81 > general queries (to be written) that will mess up raw message-ids.
\r
83 > notmuch-restore.c | 18 +-----------------
\r
84 > tag-util.c | 26 ++++++++++++++++++++------
\r
85 > tag-util.h | 5 ++++-
\r
86 > test/dump-restore | 5 ++---
\r
87 > 4 files changed, 27 insertions(+), 27 deletions(-)
\r
89 > diff --git a/notmuch-restore.c b/notmuch-restore.c
\r
90 > index 40596a8..112f2f3 100644
\r
91 > --- a/notmuch-restore.c
\r
92 > +++ b/notmuch-restore.c
\r
93 > @@ -208,24 +208,8 @@ notmuch_restore_command (unused (void *ctx), int argc, char *argv[])
\r
94 > if (input_format == DUMP_FORMAT_SUP) {
\r
95 > ret = parse_sup_line (ctx, line, &query_string, tag_ops);
\r
97 > - ret = parse_tag_line (ctx, line, TAG_FLAG_BE_GENEROUS,
\r
98 > + ret = parse_tag_line (ctx, line, TAG_FLAG_BE_GENEROUS | TAG_FLAG_ID_ONLY,
\r
99 > &query_string, tag_ops);
\r
101 > - if (ret == 0) {
\r
102 > - if (strncmp ("id:", query_string, 3) != 0) {
\r
103 > - fprintf (stderr, "Warning: unsupported query: %s\n", query_string);
\r
106 > - /* delete id: from front of string; tag_message
\r
107 > - * expects a raw message-id.
\r
109 > - * XXX: Note that query string id:foo and bar will be
\r
110 > - * interpreted as a message id "foo and bar". This
\r
111 > - * should eventually be fixed to give a better error
\r
114 > - query_string = query_string + 3;
\r
119 > diff --git a/tag-util.c b/tag-util.c
\r
120 > index e1181f8..8fea76c 100644
\r
123 > @@ -201,14 +201,28 @@ parse_tag_line (void *ctx, char *line,
\r
126 > /* tok now points to the query string */
\r
127 > - if (hex_decode_inplace (tok) != HEX_SUCCESS) {
\r
128 > - ret = line_error (TAG_PARSE_INVALID, line_for_error,
\r
129 > - "hex decoding of query %s failed", tok);
\r
131 > + if (flags & TAG_FLAG_ID_ONLY) {
\r
132 > + /* this is under the assumption that any whitespace in the
\r
133 > + * message-id must be hex-encoded. The check is probably not
\r
134 > + * perfect for exotic unicode whitespace; as fallback the
\r
135 > + * search for strange message-ids will fail */
\r
136 > + if ((strncmp ("id:", tok, 3) != 0) ||
\r
137 > + (strcspn (tok, " \t") < strlen (tok))) {
\r
138 > + ret = line_error (TAG_PARSE_INVALID, line_for_error,
\r
139 > + "query '%s' is not 'id:<message-id>'", tok);
\r
142 > + if (hex_decode_inplace (tok) != HEX_SUCCESS) {
\r
143 > + ret = line_error (TAG_PARSE_INVALID, line_for_error,
\r
144 > + "hex decoding of query %s failed", tok);
\r
147 > + /* skip 'id:' */
\r
148 > + *query_string = tok + 3;
\r
150 This looks like it doesn't double_quote the query_string in this (the
\r
151 TAG_FLAG_ID_ONLY) case. Is that deliberate?
\r
158 > + ret = quote_and_decode_query (ctx, tok, line_for_error, query_string);
\r
161 > - *query_string = tok;
\r
164 > talloc_free (line_for_error);
\r
166 > diff --git a/tag-util.h b/tag-util.h
\r
167 > index 2889736..7674051 100644
\r
170 > @@ -26,7 +26,10 @@ typedef enum {
\r
171 > /* Accept strange tags that might be user error;
\r
172 > * intended for use by notmuch-restore.
\r
174 > - TAG_FLAG_BE_GENEROUS = (1 << 3)
\r
175 > + TAG_FLAG_BE_GENEROUS = (1 << 3),
\r
177 > + /* Query consists of a single id:$message-id */
\r
178 > + TAG_FLAG_ID_ONLY = (1 << 4)
\r
182 > diff --git a/test/dump-restore b/test/dump-restore
\r
183 > index 6a989b6..eb7933a 100755
\r
184 > --- a/test/dump-restore
\r
185 > +++ b/test/dump-restore
\r
186 > @@ -199,19 +199,18 @@ a
\r
187 > # the next non-comment line should report an an empty tag error for
\r
188 > # batch tagging, but not for restore
\r
189 > + +e -- id:20091117232137.GA7669@griffis1.net
\r
190 > -# highlight the sketchy id parsing; this should be last
\r
191 > +g -- id:foo and bar
\r
194 > cat <<EOF > EXPECTED
\r
195 > -Warning: unsupported query: a
\r
196 > +Warning: query 'a' is not 'id:<message-id>' [a]
\r
197 > Warning: no query string [+0]
\r
198 > Warning: no query string [+a +b]
\r
199 > Warning: missing query string [+a +b ]
\r
200 > Warning: no query string after -- [+c +d --]
\r
201 > Warning: hex decoding of tag %zz failed [+%zz -- id:whatever]
\r
202 > Warning: hex decoding of query id:%yy failed [+e +f id:%yy]
\r
203 > -Warning: cannot apply tags to missing message: foo and bar
\r
204 > +Warning: query 'id:foo and bar' is not 'id:<message-id>' [+g -- id:foo and bar]
\r
207 > test_expect_equal_file EXPECTED OUTPUT
\r
211 > _______________________________________________
\r
212 > notmuch mailing list
\r
213 > notmuch@notmuchmail.org
\r
214 > http://notmuchmail.org/mailman/listinfo/notmuch
\r