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 4D7E3431FAF
\r
6 for <notmuch@notmuchmail.org>; Fri, 4 Jan 2013 05:55:56 -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 e1Yd0mtt9-SA for <notmuch@notmuchmail.org>;
\r
17 Fri, 4 Jan 2013 05:55:55 -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 91A16431FAE
\r
22 for <notmuch@notmuchmail.org>; Fri, 4 Jan 2013 05:55:55 -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 1Tr7kY-0002Ze-12; Fri, 04 Jan 2013 13:55:54 +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 1Tr7kX-0002Vc-HT; Fri, 04 Jan 2013 13:55:53 +0000
\r
31 From: Mark Walters <markwalters1009@gmail.com>
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: Xapian Quote tags
\r
34 User-Agent: Notmuch/0.14+236~g1d0044f (http://notmuchmail.org) Emacs/23.4.1
\r
35 (x86_64-pc-linux-gnu)
\r
36 Date: Fri, 04 Jan 2013 13:55:52 +0000
\r
37 Message-ID: <878v89hx1z.fsf@qmul.ac.uk>
\r
39 Content-Type: text/plain; charset=us-ascii
\r
40 X-Sender-Host-Address: 93.97.24.31
\r
41 X-QM-SPAM-Info: Sender has good ham record. :)
\r
42 X-QM-Body-MD5: 2da5113837db2c5d4ff5b044120fdc9b (of first 20000 bytes)
\r
43 X-SpamAssassin-Score: -1.8
\r
44 X-SpamAssassin-SpamBar: -
\r
45 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
47 spam. We require at least 5.0 points to mark a message as spam.
\r
48 This message scored -1.8 points.
\r
49 Summary of the scoring:
\r
50 * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,
\r
52 * [138.37.6.40 listed in list.dnswl.org]
\r
53 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
54 provider * (markwalters1009[at]gmail.com)
\r
55 * 0.5 AWL AWL: From: address is in the auto white-list
\r
56 X-QM-Scan-Virus: ClamAV says the message is clean
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.13
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Fri, 04 Jan 2013 13:55:56 -0000
\r
74 I would like to suggest that we Xapian quote the tags for notmuch
\r
75 dump/restore. The general view on irc is that we probably want to do
\r
76 this in the long term and I think it would be nice if we can avoid
\r
77 changing the dump format a second time.
\r
79 One problem is that our current line based parsing cannot cope with
\r
80 Xapian quoted newlines (which stay newlines). So allow a line to start
\r
81 with % which means hex-decode the whole line before passing to the main
\r
82 parser. Thus the query tags etc still need to be Xapian encoded.
\r
84 I attach a patch to show roughly what I mean. This is not complete: the
\r
85 dump routine does not hex encode lines with newlines yet, tests man
\r
86 pages etc are not updated and it is significantly unpolished. Also there
\r
87 should be some consolidation between parse_boolean_term and the
\r
88 xapian_decode routine.
\r
90 Despite the above caveats it broadly seems to work.
\r
99 >From d518e2be27ff7243ddc156699c2bfc38dec78b43 Mon Sep 17 00:00:00 2001
\r
100 From: Mark Walters <markwalters1009@gmail.com>
\r
101 Date: Fri, 4 Jan 2013 13:37:42 +0000
\r
102 Subject: [PATCH] notmuch dump: xapian quote tags
\r
105 notmuch-dump.c | 6 +++---
\r
106 tag-util.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++-------
\r
107 2 files changed, 49 insertions(+), 10 deletions(-)
\r
109 diff --git a/notmuch-dump.c b/notmuch-dump.c
\r
110 index bf01a39..e94d870 100644
\r
111 --- a/notmuch-dump.c
\r
112 +++ b/notmuch-dump.c
\r
113 @@ -120,9 +120,9 @@ notmuch_dump_command (unused (void *ctx), int argc, char *argv[])
\r
114 if (output_format == DUMP_FORMAT_SUP) {
\r
115 fputs (tag_str, output);
\r
117 - if (hex_encode (notmuch, tag_str,
\r
118 - &buffer, &buffer_size) != HEX_SUCCESS) {
\r
119 - fprintf (stderr, "Error: failed to hex-encode tag %s\n",
\r
120 + if (make_boolean_term (notmuch, NULL, tag_str,
\r
121 + &buffer, &buffer_size)) {
\r
122 + fprintf (stderr, "Error: failed to xapian-encode tag %s\n",
\r
126 diff --git a/tag-util.c b/tag-util.c
\r
127 index ca12b3b..7384afa 100644
\r
130 @@ -31,6 +31,38 @@ line_error (tag_parse_status_t status,
\r
135 +xapian_decode_tag_inplace (char *str, char* tok, size_t *tok_len)
\r
140 + if (*pos == '"') {
\r
142 + /* Skip the opening quote, find the closing quote, and
\r
143 + * un-double doubled internal quotes. */
\r
144 + for (++pos; *pos; ) {
\r
145 + if (*pos == '"') {
\r
147 + if (*pos != '"') {
\r
148 + /* Found the closing quote. */
\r
155 + if (! closed || *pos != ' ')
\r
156 + return HEX_SYNTAX_ERROR;
\r
157 + *tok_len = pos - tok;
\r
159 + out = tok + (*tok_len)++;
\r
161 + /* Terminate token */
\r
163 + return HEX_SUCCESS;
\r
167 parse_tag_line (void *ctx, char *line,
\r
168 tag_op_flag_t flags,
\r
169 @@ -60,6 +92,15 @@ parse_tag_line (void *ctx, char *line,
\r
173 + if (*tok == '%') {
\r
175 + if (hex_decode_inplace (tok) != HEX_SUCCESS) {
\r
176 + ret = line_error (TAG_PARSE_INVALID, line_for_error,
\r
177 + "hex decoding of line failed", "");
\r
182 tag_op_list_reset (tag_ops);
\r
185 @@ -89,23 +130,21 @@ parse_tag_line (void *ctx, char *line,
\r
189 - /* Terminate, and start next token after terminator. */
\r
190 - *(tok + tok_len++) = '\0';
\r
192 remove = (*tok == '-');
\r
195 - /* Maybe refuse empty tags. */
\r
196 + /* Maybe refuse empty tags. Note a quoted empty tag is allowed. */
\r
197 if (! (flags & TAG_FLAG_BE_GENEROUS) && *tag == '\0') {
\r
198 ret = line_error (TAG_PARSE_INVALID, line_for_error,
\r
203 - /* Decode tag. */
\r
204 - if (hex_decode_inplace (tag) != HEX_SUCCESS) {
\r
205 + /* Find real (quoted) end, terminate, and start next token
\r
206 + * after terminator. */
\r
207 + if (xapian_decode_tag_inplace (tag, tok, &tok_len) != HEX_SUCCESS) {
\r
208 ret = line_error (TAG_PARSE_INVALID, line_for_error,
\r
209 - "hex decoding of tag %s failed", tag);
\r
210 + "xapian decoding of tag %s failed", tag);
\r