summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2025-09-12 19:46:23 +0300
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2025-09-12 19:06:21 +0300
commit8209e802e3c331e2dd0eb67fce18aa2a3019fed4 (patch)
tree519b16498bfe829a0f7c91e011b81cc75625efce
parent97d6a41823a76351ed26693b8db167cc6ee14881 (diff)
labels: tighten labels regexp
-rw-r--r--lib/message/mu-labels.cc11
-rw-r--r--man/mu-labels.1.org14
2 files changed, 15 insertions, 10 deletions
diff --git a/lib/message/mu-labels.cc b/lib/message/mu-labels.cc
index c3822dd..87b92e3 100644
--- a/lib/message/mu-labels.cc
+++ b/lib/message/mu-labels.cc
@@ -51,16 +51,16 @@ Mu::Labels::validate_label(const std::string &label)
if (::iscntrl(uc))
return Err(Error{Error::Code::InvalidArgument,
- "control character {} is not allowed",
+ "control character {} not allowed in label",
static_cast<int>(uc)});
if (::isblank(uc))
return Err(Error{Error::Code::InvalidArgument,
- "blank character {} is not allowed",
+ "blank character {} not allowed in label",
static_cast<int>(uc)});
- if (uc == '"' || uc == '\'' || uc == '`' ||
+ if (uc == '"' || uc == '\'' || uc == '`' || uc == ',' ||
uc == '\\' || uc == '/' || uc == '$')
return Err(Error{Error::Code::InvalidArgument,
- "character '{}' is not allowed", uc});
+ "character '{}' not allowed in label", uc});
}
return Ok();
@@ -217,11 +217,14 @@ test_validate_label()
g_assert_true(!!validate_label("@raven+king"));
g_assert_true(!!validate_label("operation:mindcrime"));
g_assert_true(!!validate_label("😨"));
+ g_assert_true(!!validate_label("foo%bar+1"));
g_assert_false(!!validate_label("norrell strange"));
g_assert_false(!!validate_label(""));
g_assert_false(!!validate_label("+"));
g_assert_false(!!validate_label("-"));
+ g_assert_false(!!validate_label("foo$bar"));
+ g_assert_false(!!validate_label("foo,bar"));
g_assert_false(!!validate_label("foo`bar"));
g_assert_false(!!validate_label("\"quoted\""));
}
diff --git a/man/mu-labels.1.org b/man/mu-labels.1.org
index 88ed0f2..ad70479 100644
--- a/man/mu-labels.1.org
+++ b/man/mu-labels.1.org
@@ -119,8 +119,8 @@ See *EXPORT FORMAT* below for details on the format.
*mu* does not wish to limit your creativity, but nevertheless puts a few
restrictions on what is accepted as a label.
-- a *valid label character* is any character that is not a control-character, a
- blank, or any of *'*, *"*, *`*, */*, *\*, *$*
+- a *valid label character* is any character that is not a control-character, not
+ a blank, nor anything matching the regular expression ~[^\"$',/\\`]~
- a *valid label* consists of one or more valid label characters, the first of
which must *not* be either *+* or *-*
@@ -165,14 +165,16 @@ it is recognized as a single parameter.
Remove the label "planet" and add the label "dwarf-planet" to all messages that
have "pluto" in their subject:
-#+begin_export
+
+#+begin_example
$ mu labels update "subject:pluto" --labels -planet,+dwarf-planet
-#+end_export
+#+end_example
Clear all labels from messages with the label "boring":
-#+begin_export
+
+#+begin_example
$ mu labels clear "label:boring"
-#+end_export
+#+end_example
#+include: "prefooter.inc" :minlevel 1