summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-private/private-list.cc9
-rwxr-xr-xtest/integration/test-apt-patterns8
2 files changed, 9 insertions, 8 deletions
diff --git a/apt-private/private-list.cc b/apt-private/private-list.cc
index f5c31bbcd..eee657c46 100644
--- a/apt-private/private-list.cc
+++ b/apt-private/private-list.cc
@@ -39,6 +39,7 @@ struct PackageSortAlphabetic /*{{{*/
class PackageNameMatcher : public Matcher
{
+ static constexpr const char *const isfnmatch_strict = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-.:*";
pkgCacheFile &cacheFile;
public:
explicit PackageNameMatcher(pkgCacheFile &cacheFile, const char **patterns)
@@ -48,12 +49,12 @@ class PackageNameMatcher : public Matcher
{
std::string pattern = patterns[i];
APT::CacheFilter::Matcher *cachefilter = NULL;
- if (pattern.size() > 0 && (pattern[0] == '?' || pattern[0] == '~'))
- cachefilter = APT::CacheFilter::ParsePattern(pattern, &cacheFile).release();
- else if(_config->FindB("APT::Cmd::Use-Regexp", false) == true)
+ if(_config->FindB("APT::Cmd::Use-Regexp", false) == true)
cachefilter = new APT::CacheFilter::PackageNameMatchesRegEx(pattern);
- else
+ else if (pattern.find_first_not_of(isfnmatch_strict) == std::string::npos)
cachefilter = new APT::CacheFilter::PackageNameMatchesFnmatch(pattern);
+ else
+ cachefilter = APT::CacheFilter::ParsePattern(pattern, &cacheFile).release();
if (cachefilter == nullptr) {
return;
diff --git a/test/integration/test-apt-patterns b/test/integration/test-apt-patterns
index b091c8729..33df21d36 100755
--- a/test/integration/test-apt-patterns
+++ b/test/integration/test-apt-patterns
@@ -256,10 +256,10 @@ E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or speci
# other wildcards should fail
-# FIXME: This should fail
-testsuccessequal "Listing...
-automatic1/now 1.0 i386 [installed,local]
-automatic2/now 1.0 i386 [installed,local]" apt list 'automatic?'
+testfailureequal "Listing...
+E: input:0-10: error: Expected pattern
+ automatic?
+ ^^^^^^^^^^" apt list 'automatic?'