summaryrefslogtreecommitdiff
path: root/apt-pkg/cacheset.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2020-01-15 22:01:54 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2020-01-15 22:19:17 +0100
commit21cb4a9e513ccb6f376fbcaf67957c4851cbbe32 (patch)
treed18cb6cf693d955e8d4b38300981e23938b9f995 /apt-pkg/cacheset.cc
parent5db3a38926aa820546c411dd9f49f57eea24cd9e (diff)
apt(8): Disable regular expressions and fnmatch
This is the first step. Next step will be to add warnings to apt-get and then remove support there as well.
Diffstat (limited to 'apt-pkg/cacheset.cc')
-rw-r--r--apt-pkg/cacheset.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc
index dd55edb4e..f5251eda8 100644
--- a/apt-pkg/cacheset.cc
+++ b/apt-pkg/cacheset.cc
@@ -125,8 +125,16 @@ bool CacheSetHelper::PackageFromTask(PackageContainerInterface * const pci, pkgC
// PackageFromRegEx - Return all packages in the cache matching a pattern /*{{{*/
bool CacheSetHelper::PackageFromRegEx(PackageContainerInterface * const pci, pkgCacheFile &Cache, std::string pattern) {
static const char * const isregex = ".?+*|[^$";
- if (pattern.find_first_of(isregex) == std::string::npos)
- return false;
+
+ if (_config->FindB("APT::Cmd::Pattern-Only", false))
+ {
+ // Only allow explicit regexp pattern.
+ if (pattern.size() == 0 || (pattern[0] != '^' && pattern[pattern.size() - 1] != '$'))
+ return false;
+ } else {
+ if (pattern.find_first_of(isregex) == std::string::npos)
+ return false;
+ }
bool const wasEmpty = pci->empty();
if (wasEmpty == true)
@@ -181,6 +189,8 @@ bool CacheSetHelper::PackageFromFnmatch(PackageContainerInterface * const pci,
pkgCacheFile &Cache, std::string pattern)
{
static const char * const isfnmatch = ".?*[]!";
+ if (_config->FindB("APT::Cmd::Pattern-Only", false))
+ return false;
if (pattern.find_first_of(isfnmatch) == std::string::npos)
return false;