From 62f0cbc2f9affa8d7578f3b78e93a4fa5dd51054 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Sun, 23 Feb 2014 18:55:20 +0200 Subject: [PATCH] [PATCH 0/3] check new.tags for invalid tags --- 99/e625582e2ed24e7bb546bd0e69967b7e1b263e | 108 ++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 99/e625582e2ed24e7bb546bd0e69967b7e1b263e diff --git a/99/e625582e2ed24e7bb546bd0e69967b7e1b263e b/99/e625582e2ed24e7bb546bd0e69967b7e1b263e new file mode 100644 index 000000000..a03cf59b7 --- /dev/null +++ b/99/e625582e2ed24e7bb546bd0e69967b7e1b263e @@ -0,0 +1,108 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 1A37C429E32 + for ; Sun, 23 Feb 2014 08:55:39 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id NRCDxlebVxTe for ; + Sun, 23 Feb 2014 08:55:33 -0800 (PST) +Received: from mail-ee0-f42.google.com (mail-ee0-f42.google.com + [74.125.83.42]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client + certificate requested) by olra.theworths.org (Postfix) with ESMTPS id + 53412431FD8 for ; Sun, 23 Feb 2014 08:55:31 -0800 + (PST) +Received: by mail-ee0-f42.google.com with SMTP id e53so1085795eek.29 + for ; Sun, 23 Feb 2014 08:55:27 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to + :references; + bh=j4xJ+TiJeAuK1GA4z2ixk2nLz8qpGNwCBGGck+/yhwU=; + b=AC9AtFG/87cNBavpZPuJ9IqJq1jgx/3Kr8AMToBonvL0/XeJWdh2onf4uFRmw0eBx3 + fMv8VhkwrGO1cv+yylFBW4jkHqERCnwGqoCtX3XF01Dt9CreP5lU6qn8PeznZxMfUPvn + QWdElRhfWzJq57swnieoiGRqEXhPQieTVRX45O4gnlxrihKL78OeensQUjmHf2rMuGge + jcuAvgA17653+WvGsEMw/erGkGVgbEgb2ddfnjjhkNu5lP2ver64Dobos0kKe+r/nGa/ + rUenpstYrGBHVjqMeJdEFr/UuWWfb1zK9TPKNwJeD9nn7fImfR9CvUjKwTIlfKgY6rFj + nJEw== +X-Gm-Message-State: + ALoCoQkl4zZkIVpc9XJsg1LoFUcU6FpGaBhxlQIcE80ObGEjdaySQsh85sKxgNQOmxVe82XF/NTa +X-Received: by 10.15.48.1 with SMTP id g1mr19451364eew.51.1393174527246; + Sun, 23 Feb 2014 08:55:27 -0800 (PST) +Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. + [88.195.111.91]) + by mx.google.com with ESMTPSA id m1sm53062062een.7.2014.02.23.08.55.25 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sun, 23 Feb 2014 08:55:26 -0800 (PST) +From: Jani Nikula +To: notmuch@notmuchmail.org, + Rob Browning +Subject: [PATCH 0/3] check new.tags for invalid tags +Date: Sun, 23 Feb 2014 18:55:20 +0200 +Message-Id: +X-Mailer: git-send-email 1.8.5.3 +In-Reply-To: <87ha7qfto7.fsf@trouble.defaultvalue.org> +References: <87ha7qfto7.fsf@trouble.defaultvalue.org> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sun, 23 Feb 2014 16:55:39 -0000 + +On Sun, 23 Feb 2014, Rob Browning wrote: +> In the [new] section, "tags=;" will cause notmuch to create empty tags +> that are fairly hard to remove from the command line. + +Clearly broken. This series fixes the issue at the cli +level. (Forbidding empty tags at the lib level is slightly more +complicated, as we would still have to ensure old dump files can be +restored.) + +> After some help on #bup, here's what I came up with to remove them, +> though it assumes that the empty tag "+ " will always be first in dump's +> output: +> +> notmuch dump --format=batch-tag 'tag:""' | perl -pe 's/^\+ //' \ +> | notmuch restore --format=batch-tag +> +> And note that you have to use restore, "notmuch tag --batch" doesn't +> appear to accept "- " as a tag, even though dump will produce "+ ". + +I didn't check this further, but the regular, non-batch notmuch tag +should still work for removal of empty tags. + +BR, +Jani. + +Jani Nikula (3): + cli: export function for illegal tag checking + cli: make sure notmuch new and insert don't add invalid tags + test: add tests for invalid new.tags + + notmuch-insert.c | 9 +++++++++ + notmuch-new.c | 14 +++++++++++++- + tag-util.c | 9 +-------- + tag-util.h | 12 ++++++++++++ + test/T050-new.sh | 17 +++++++++++++++++ + test/T070-insert.sh | 19 +++++++++++++++++++ + 6 files changed, 71 insertions(+), 9 deletions(-) + +-- +1.8.5.3 + -- 2.26.2