[PATCH 02/11] cli/insert: rename check_folder_name to is_valid_folder_name
authorJani Nikula <jani@nikula.org>
Mon, 22 Sep 2014 09:54:53 +0000 (11:54 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 18:04:38 +0000 (10:04 -0800)
f9/6570a876dc0d4ff1f36a9bd8b0aeb34281f555 [new file with mode: 0644]

diff --git a/f9/6570a876dc0d4ff1f36a9bd8b0aeb34281f555 b/f9/6570a876dc0d4ff1f36a9bd8b0aeb34281f555
new file mode 100644 (file)
index 0000000..68e7cfa
--- /dev/null
@@ -0,0 +1,112 @@
+Return-Path: <jani@nikula.org>\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 2FCE3431FB6\r
+       for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 02:54:59 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 92e17x6fqpmf for <notmuch@notmuchmail.org>;\r
+       Mon, 22 Sep 2014 02:54:54 -0700 (PDT)\r
+Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
+       [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 46F16431FC3\r
+       for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 02:54:51 -0700 (PDT)\r
+Received: by mail-wi0-f181.google.com with SMTP id z2so2607626wiv.8\r
+       for <notmuch@notmuchmail.org>; Mon, 22 Sep 2014 02:54:50 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=1e100.net; s=20130820;\r
+       h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+       :references:in-reply-to:references;\r
+       bh=BnALWtTzG3/QUxA4HNgdSMGE4TMNTwo6KMYLSHf6SPA=;\r
+       b=L2P9Q3sP2CFs9NWnhbEGYGlHfMKCp+87z3q/wOP5vo6Z11gRihk62qX26ZoNeO7QEP\r
+       7VKybyMTAiukg6ZFr62NhO1x1zplwzPQH5ah2FO5jY0IdLERNv8qYc8n5XUCaYgl50cX\r
+       9bxN60qSaFC/Xvr08fCJedNuFRQHKv0E+hOGfDaG49g59UXoG4r7vHGYvw6AH1ENtJ/G\r
+       4zGJfdYEuHf6BZY5fXWCbbim2lJOYBXvP9yhvwGXugqmFR3F7XLrCH5AfsKjaqN783jV\r
+       yo7eR0fzIcrQKll0ZnWN8VCAtCncQv2kgxfd7zdVdswkp/lqxrfk/pYI1oFzGA3oO1lI\r
+       G6kA==\r
+X-Gm-Message-State:\r
+ ALoCoQkz2tKQNPv4itfIvO5a9g8EhXpeNp449lNSzPo1sLIT5WJ+XCw1idlOZmoYSjdpZ4ONSPKA\r
+X-Received: by 10.194.203.8 with SMTP id km8mr19296884wjc.51.1411379690249;\r
+       Mon, 22 Sep 2014 02:54:50 -0700 (PDT)\r
+Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3])\r
+       by mx.google.com with ESMTPSA id mc4sm4390990wic.6.2014.09.22.02.54.49\r
+       for <multiple recipients>\r
+       (version=TLSv1.1 cipher=RC4-SHA bits=128/128);\r
+       Mon, 22 Sep 2014 02:54:49 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 02/11] cli/insert: rename check_folder_name to\r
+       is_valid_folder_name\r
+Date: Mon, 22 Sep 2014 11:54:53 +0200\r
+Message-Id:\r
+ <bbd8752e33eb89136c06af49e7d388455666a00a.1411379395.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.2.5\r
+In-Reply-To: <cover.1411379395.git.jani@nikula.org>\r
+References: <cover.1411379395.git.jani@nikula.org>\r
+In-Reply-To: <cover.1411379395.git.jani@nikula.org>\r
+References: <cover.1411379395.git.jani@nikula.org>\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: Mon, 22 Sep 2014 09:54:59 -0000\r
+\r
+An "is something" predicate conveys the meaning better. While at it,\r
+improve the function documentation and error message. Besides the\r
+error message change, no functional changes.\r
+---\r
+ notmuch-insert.c |   13 ++++++++-----\r
+ 1 files changed, 8 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/notmuch-insert.c b/notmuch-insert.c\r
+index 8dfc8bb..770275b 100644\r
+--- a/notmuch-insert.c\r
++++ b/notmuch-insert.c\r
+@@ -83,10 +83,13 @@ sync_dir (const char *dir)\r
+     return ret;\r
+ }\r
\r
+-/* Check the specified folder name does not contain a directory\r
+- * component ".." to prevent writes outside of the Maildir hierarchy. */\r
++/*\r
++ * Check the specified folder name does not contain a directory\r
++ * component ".." to prevent writes outside of the Maildir\r
++ * hierarchy. Return TRUE on valid folder name, FALSE otherwise.\r
++ */\r
+ static notmuch_bool_t\r
+-check_folder_name (const char *folder)\r
++is_valid_folder_name (const char *folder)\r
+ {\r
+     const char *p = folder;\r
\r
+@@ -449,8 +452,8 @@ notmuch_insert_command (notmuch_config_t *config, int argc, char *argv[])\r
+     if (folder == NULL) {\r
+       maildir = db_path;\r
+     } else {\r
+-      if (! check_folder_name (folder)) {\r
+-          fprintf (stderr, "Error: bad folder name: %s\n", folder);\r
++      if (! is_valid_folder_name (folder)) {\r
++          fprintf (stderr, "Error: invalid folder name: '%s'\n", folder);\r
+           return EXIT_FAILURE;\r
+       }\r
+       maildir = talloc_asprintf (config, "%s/%s", db_path, folder);\r
+-- \r
+1.7.2.5\r
+\r