summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/cachefilter-patterns.cc5
-rw-r--r--test/libapt/pattern_test.cc2
2 files changed, 6 insertions, 1 deletions
diff --git a/apt-pkg/cachefilter-patterns.cc b/apt-pkg/cachefilter-patterns.cc
index bc0eece30..fded7d92f 100644
--- a/apt-pkg/cachefilter-patterns.cc
+++ b/apt-pkg/cachefilter-patterns.cc
@@ -333,9 +333,12 @@ std::unique_ptr<PatternTreeParser::Node> PatternTreeParser::parseQuotedWord()
// Parse a bare word atom
std::unique_ptr<PatternTreeParser::Node> PatternTreeParser::parseWord(bool shrt)
{
+ // Characters not allowed at the start of a word (also see ..._SHRT)
static const constexpr auto DISALLOWED_START = "!?~|,() \0"_sv;
+ // Characters terminating a word inside a long pattern
static const constexpr auto DISALLOWED_LONG = "|,()\0"_sv;
- static const constexpr auto DISALLOWED_SHRT = "|,() ?\0"_sv;
+ // Characters terminating a word as a short form argument, should contain all of START.
+ static const constexpr auto DISALLOWED_SHRT = "!?~|,() \0"_sv;
const auto DISALLOWED = shrt ? DISALLOWED_SHRT : DISALLOWED_LONG;
if (DISALLOWED_START.find(sentence[state.offset]) != APT::StringView::npos)
diff --git a/test/libapt/pattern_test.cc b/test/libapt/pattern_test.cc
index bfcaf2093..55bc4bdcf 100644
--- a/test/libapt/pattern_test.cc
+++ b/test/libapt/pattern_test.cc
@@ -219,4 +219,6 @@ TEST(TreeParserTest, ParseShortPattern)
EXPECT_PATTERN_EQ("?A|?B?C", "?or(?A, ?and(?B, ?C))");
EXPECT_PATTERN_EQ("?A|(?B?C)", "?or(?A, ?and(?B, ?C))");
EXPECT_PATTERN_EQ("(?B?C)|?A", "?or(?and(?B, ?C), ?A)");
+ EXPECT_PATTERN_EQ("~napt~nfoo", "?and(?name(apt),?name(foo))");
+ EXPECT_PATTERN_EQ("~napt!~nfoo", "?and(?name(apt),?not(?name(foo)))");
}