summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2019-08-15 15:06:20 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2019-08-19 14:31:17 +0200
commitd18b6095862e8268b4d2cd8c0b3140829a1e4950 (patch)
treefe9664d72c563e00e63e4acd83e6c1b21f8fa12c
parentd64f0f343d2fcfe1d7768fa9acad83e34fa519f2 (diff)
downloadapt-d18b6095862e8268b4d2cd8c0b3140829a1e4950.tar.gz
patterns: Allow more complex words
Only disallow ,() and on the start of a word also ~ and ?. Make sure to include \0 as disallowed.
-rw-r--r--apt-pkg/cachefilter-patterns.cc10
1 files changed, 4 insertions, 6 deletions
diff --git a/apt-pkg/cachefilter-patterns.cc b/apt-pkg/cachefilter-patterns.cc
index 1f448dae9..bf6166ee4 100644
--- a/apt-pkg/cachefilter-patterns.cc
+++ b/apt-pkg/cachefilter-patterns.cc
@@ -144,17 +144,15 @@ std::unique_ptr<PatternTreeParser::Node> PatternTreeParser::parseQuotedWord()
// Parse a bare word atom
std::unique_ptr<PatternTreeParser::Node> PatternTreeParser::parseWord()
{
- static const APT::StringView CHARS("0123456789"
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "-.*^$[]_\\");
- if (CHARS.find(sentence[state.offset]) == APT::StringView::npos)
+ static const APT::StringView DISALLOWED_START("?~,()\0", 6);
+ static const APT::StringView DISALLOWED(",()\0", 4);
+ if (DISALLOWED_START.find(sentence[state.offset]) != APT::StringView::npos)
return nullptr;
auto node = std::make_unique<WordNode>();
node->start = state.offset;
- while (CHARS.find(sentence[state.offset]) != APT::StringView::npos)
+ while (DISALLOWED.find(sentence[state.offset]) == APT::StringView::npos)
state.offset++;
node->end = state.offset;