1 Return-Path: <jani@nikula.org>
\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 76B48431FC4
\r
6 for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 14:32:56 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id ro3eFkuwn6iX for <notmuch@notmuchmail.org>;
\r
16 Sat, 27 Apr 2013 14:32:56 -0700 (PDT)
\r
17 Received: from mail-la0-f51.google.com (mail-la0-f51.google.com
\r
18 [209.85.215.51]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id B9270431FC2
\r
21 for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 14:32:55 -0700 (PDT)
\r
22 Received: by mail-la0-f51.google.com with SMTP id ep20so749738lab.24
\r
23 for <notmuch@notmuchmail.org>; Sat, 27 Apr 2013 14:32:54 -0700 (PDT)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=google.com; s=20120113;
\r
26 h=x-received:from:to:subject:in-reply-to:references:user-agent:date
\r
27 :message-id:mime-version:content-type:x-gm-message-state;
\r
28 bh=gu24WgPMIHhGpC6Ex3Gjb0cGlNr/LYlLofm71iaNwp8=;
\r
29 b=CDqJa+cUucUCDsuohboON0NmqSkcbH9MthdEmspIThseU2SOypPEFRMUNNuGyjrNT9
\r
30 sx7WHWyo9EcAW23TLwCWJqnPxxz5wZnu0Ga/ayXQdc1oWNubNfHQhpt2gXFF//E0cee4
\r
31 7Qo8e1oqsCO2lCpo/zx1g7IFKUYAnpQdnW3RdvZ+mNbBINU7DgufkqcvjZ6i5ieza8LH
\r
32 U9fCWHocMNaQPQfydy4ODENvEhz18HavsuArcsVxWsY0+yhuAtug7KdO5oWRrsff3Lk/
\r
33 ZDaX4Su40Fjoqr0rheTS/4QSt6gbxWEBtNHxtyyjjva9K9GPf5r9qX+NV2S+XZ2GBwLK
\r
35 X-Received: by 10.152.4.100 with SMTP id j4mr24628255laj.14.1367098374307;
\r
36 Sat, 27 Apr 2013 14:32:54 -0700 (PDT)
\r
37 Received: from localhost (dsl-hkibrasgw2-58c376-211.dhcp.inet.fi.
\r
39 by mx.google.com with ESMTPSA id t20sm6783560lbi.5.2013.04.27.14.32.53
\r
40 for <multiple recipients>
\r
41 (version=TLSv1.2 cipher=RC4-SHA bits=128/128);
\r
42 Sat, 27 Apr 2013 14:32:53 -0700 (PDT)
\r
43 From: Jani Nikula <jani@nikula.org>
\r
44 To: Peter Wang <novalazy@gmail.com>, notmuch@notmuchmail.org
\r
45 Subject: Re: [PATCH v5 07/12] insert: add --folder option
\r
46 In-Reply-To: <1364942517-6982-8-git-send-email-novalazy@gmail.com>
\r
47 References: <1364942517-6982-1-git-send-email-novalazy@gmail.com>
\r
48 <1364942517-6982-8-git-send-email-novalazy@gmail.com>
\r
49 User-Agent: Notmuch/0.15.2+70~g2eeb96a (http://notmuchmail.org) Emacs/24.2.1
\r
50 (x86_64-pc-linux-gnu)
\r
51 Date: Sun, 28 Apr 2013 00:32:47 +0300
\r
52 Message-ID: <87zjwjpslc.fsf@nikula.org>
\r
54 Content-Type: text/plain
\r
56 ALoCoQk60lUsm6xCtoFT1TFNSC8fRbpBB1Mfgzim1qOTPt8iruQPZECubB2vDB/7Iehtz5XcESBw
\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: Sat, 27 Apr 2013 21:32:56 -0000
\r
71 On Wed, 03 Apr 2013, Peter Wang <novalazy@gmail.com> wrote:
\r
72 > Allow the new message to be inserted into a folder within the Maildir
\r
73 > hierarchy instead of the top-level folder.
\r
75 > notmuch-insert.c | 47 +++++++++++++++++++++++++++++++++++++++++++++--
\r
76 > 1 file changed, 45 insertions(+), 2 deletions(-)
\r
78 > diff --git a/notmuch-insert.c b/notmuch-insert.c
\r
79 > index 19b1cf9..778ac04 100644
\r
80 > --- a/notmuch-insert.c
\r
81 > +++ b/notmuch-insert.c
\r
82 > @@ -83,6 +83,23 @@ sync_dir (const char *dir)
\r
86 > +/* Check the specified folder name does not contain a directory
\r
87 > + * component ".." to prevent writes outside of the Maildir hierarchy. */
\r
88 > +static notmuch_bool_t
\r
89 > +check_folder_name (const char *folder)
\r
91 > + const char *p = folder;
\r
94 > + if ((p[0] == '.') && (p[1] == '.') && (p[2] == '\0' || p[2] == '/'))
\r
96 > + p = strchr (p, '/');
\r
103 > /* Open a unique file in the Maildir 'tmp' directory.
\r
104 > * Returns the file descriptor on success, or -1 on failure.
\r
105 > * On success, file paths for the message in the 'tmp' and 'new'
\r
106 > @@ -287,11 +304,25 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
\r
107 > size_t new_tags_length;
\r
108 > tag_op_list_t *tag_ops;
\r
109 > char *query_string = NULL;
\r
110 > + const char *folder = NULL;
\r
111 > const char *maildir;
\r
112 > - int opt_index = 1;
\r
115 > notmuch_bool_t ret;
\r
117 > + notmuch_opt_desc_t options[] = {
\r
118 > + { NOTMUCH_OPT_STRING, &folder, "folder", 0, 0 },
\r
119 > + { NOTMUCH_OPT_END, 0, 0, 0, 0 }
\r
122 > + opt_index = parse_arguments (argc, argv, options, 1);
\r
124 > + if (opt_index < 0) {
\r
125 > + fprintf (stderr, "Error: bad argument to notmuch insert: %s\n",
\r
126 > + argv[-opt_index]);
\r
128 I'm too tired to check what's correct, but argv[-opt_index] isn't.
\r
136 > db_path = notmuch_config_get_database_path (config);
\r
137 > new_tags = notmuch_config_get_new_tags (config, &new_tags_length);
\r
139 > @@ -314,7 +345,19 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])
\r
143 > - maildir = db_path;
\r
144 > + if (folder == NULL) {
\r
145 > + maildir = db_path;
\r
147 > + if (! check_folder_name (folder)) {
\r
148 > + fprintf (stderr, "Error: bad folder name: %s\n", folder);
\r
151 > + maildir = talloc_asprintf (config, "%s/%s", db_path, folder);
\r
152 > + if (! maildir) {
\r
153 > + fprintf (stderr, "Out of memory\n");
\r
158 > /* Setup our handler for SIGINT. We do not set SA_RESTART so that copying
\r
159 > * from standard input may be interrupted. */
\r
163 > _______________________________________________
\r
164 > notmuch mailing list
\r
165 > notmuch@notmuchmail.org
\r
166 > http://notmuchmail.org/mailman/listinfo/notmuch
\r