[PATCH 06/10] cli: Introduce "notmuch address" command
[notmuch-archives.git] / c0 / 5eb8f58d677016048ef49b3ed73049027feea8
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 20623431FB6\r
6         for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 09:50:05 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.098\r
10 X-Spam-Level: \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 kK3xDGp7cipu for <notmuch@notmuchmail.org>;\r
17         Sat, 15 Dec 2012 09:50:01 -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 28925431FBC\r
22         for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 09:50:01 -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 1Tjvs2-0004Vc-Gh; Sat, 15 Dec 2012 17:49:56 +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 1Tjvs2-00001O-3Q; Sat, 15 Dec 2012 17:49:54 +0000\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: david@tethera.net, notmuch@notmuchmail.org\r
33 Subject: Re: [Patch v7 05/14] quote_and_decode_query: new function to quote\r
34         hex-decoded queries\r
35 In-Reply-To: <1355492062-7546-6-git-send-email-david@tethera.net>\r
36 References: <1355492062-7546-1-git-send-email-david@tethera.net>\r
37         <1355492062-7546-6-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:49:55 +0000\r
41 Message-ID: <87zk1f8at8.fsf@qmul.ac.uk>\r
42 MIME-Version: 1.0\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: 38bb0874714125ffc2484fd026037717 (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
50         determine if it is\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
55         *      medium trust\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
64 Precedence: list\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:50:05 -0000\r
75 \r
76 \r
77 On Fri, 14 Dec 2012, david@tethera.net wrote:\r
78 > From: David Bremner <bremner@debian.org>\r
79 >\r
80 > The query is split into tokens, with ' ' and ':' as delimiters.  Any\r
81 > token containing some hex-escaped character is quoted according to\r
82 > Xapian rules.  This maps id:foo%20%22bar to id:"foo ""bar".\r
83 > This intentionally does not quote prefixes, so they still work as prefixes.\r
84 > ---\r
85 >  tag-util.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
86 >  1 file changed, 50 insertions(+)\r
87 >\r
88 > diff --git a/tag-util.c b/tag-util.c\r
89 > index f89669a..e1181f8 100644\r
90 > --- a/tag-util.c\r
91 > +++ b/tag-util.c\r
92 > @@ -56,6 +56,56 @@ illegal_tag (const char *tag, notmuch_bool_t remove)\r
93 >      return NULL;\r
94 >  }\r
95 >  \r
96 > +static tag_parse_status_t\r
97 > +quote_and_decode_query (void *ctx, char *encoded, const char *line_for_error,\r
98 > +                     char **query_string)\r
99 > +{\r
100 \r
101 Would decode_and_quote_query be a better name given the order these two\r
102 happen? Also a comment describing the function would be nice.\r
103 \r
104 > +    char *tok = encoded;\r
105 > +    size_t tok_len = 0;\r
106 > +    char *buf = NULL;\r
107 > +    size_t buf_len = 0;\r
108 > +    tag_parse_status_t ret = TAG_PARSE_SUCCESS;\r
109 > +\r
110 > +    *query_string = talloc_strdup (ctx, "");\r
111 > +\r
112 > +    while (*query_string &&\r
113 > +        (tok = strtok_len (tok + tok_len, ": ", &tok_len)) != NULL) {\r
114 > +     char delim = tok[tok_len];\r
115 > +\r
116 > +     *(tok + tok_len++) = '\0';\r
117 \r
118 These two look a little odd: I would prefer either array or pointer in\r
119 both cases.\r
120 \r
121 > +\r
122 > +     if (strcspn (tok, "%") < tok_len - 1) {\r
123 > +         /* something to decode */\r
124 > +         if (hex_decode_inplace (tok) != HEX_SUCCESS) {\r
125 > +             ret = line_error (TAG_PARSE_INVALID, line_for_error,\r
126 > +                               "hex decoding of token '%s' failed", tok);\r
127 > +             goto DONE;\r
128 > +         }\r
129 > +\r
130 > +         if (double_quote_str (ctx, tok, &buf, &buf_len)) {\r
131 > +             ret = line_error (TAG_PARSE_OUT_OF_MEMORY,\r
132 > +                               line_for_error, "aborting");\r
133 > +             goto DONE;\r
134 > +         }\r
135 > +         *query_string = talloc_asprintf_append_buffer (\r
136 > +             *query_string, "%s%c", buf, delim);\r
137 > +\r
138 > +     } else {\r
139 > +         /* This is not just an optimization, but used to preserve\r
140 > +          * prefixes like id:, which cannot be quoted.\r
141 > +          */\r
142 > +         *query_string = talloc_asprintf_append_buffer (\r
143 > +             *query_string, "%s%c", tok, delim);\r
144 > +     }\r
145 \r
146 What happens if a message id (for example) contains a ':'? Is a query of\r
147 the form \r
148 \r
149 id:stuff"encoded_stuff" \r
150 \r
151 acceptable? (As far as I can see from the man page ':' does not need to\r
152 be in hex.)\r
153 \r
154 Best wishes\r
155 \r
156 Mark\r
157 \r
158 \r
159 > +\r
160 > +    }\r
161 > +\r
162 > +  DONE:\r
163 > +    if (ret != TAG_PARSE_SUCCESS && *query_string)\r
164 > +     talloc_free (*query_string);\r
165 > +    return ret;\r
166 > +}\r
167 > +\r
168 >  tag_parse_status_t\r
169 >  parse_tag_line (void *ctx, char *line,\r
170 >               tag_op_flag_t flags,\r
171 > -- \r
172 > 1.7.10.4\r
173 >\r
174 > _______________________________________________\r
175 > notmuch mailing list\r
176 > notmuch@notmuchmail.org\r
177 > http://notmuchmail.org/mailman/listinfo/notmuch\r