From d18b6095862e8268b4d2cd8c0b3140829a1e4950 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 15 Aug 2019 15:06:20 +0200 Subject: patterns: Allow more complex words Only disallow ,() and on the start of a word also ~ and ?. Make sure to include \0 as disallowed. --- apt-pkg/cachefilter-patterns.cc | 10 ++++------ 1 file 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::parseQuotedWord() // Parse a bare word atom std::unique_ptr 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(); 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; -- cgit v1.2.3-70-g09d2