From a3a1f49be108c4dca747de821dcdfb66ca2656ff Mon Sep 17 00:00:00 2001 From: Soren Bjornstad Date: Fri, 28 Aug 2020 15:59:31 -0500 Subject: [PATCH 1/2] fix unanchored regex in bulk tag add routine Previously, it was not possible to add a substring of an existing tag. For example, with the tag "foobar", you could not add the tag "foo", "bar" or "oob". Because the match was unanchored, the regex checking whether the tag already existed determined that the tag was present when it was not. --- rslib/src/tags.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rslib/src/tags.rs b/rslib/src/tags.rs index f1ef9e306..b5e439476 100644 --- a/rslib/src/tags.rs +++ b/rslib/src/tags.rs @@ -152,7 +152,7 @@ impl Collection { let matcher = regex::RegexSet::new( tags.iter() .map(|s| regex::escape(s)) - .map(|s| format!("(?i){}", s)), + .map(|s| format!("(?i)^{}$", s)), ) .map_err(|_| AnkiError::invalid_input("invalid regex"))?; From 18cae3e7571dbe30f1d5c81fabed6f28e9c406d3 Mon Sep 17 00:00:00 2001 From: Soren Bjornstad Date: Fri, 28 Aug 2020 16:22:03 -0500 Subject: [PATCH 2/2] add myself to CONTRIBUTORS --- CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 93bc5f81d..81b10b43a 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -47,6 +47,7 @@ Alexander Presnyakov abdo aplaice phwoo +Soren Bjornstad ********************