summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2020-01-15 22:02:32 +0000
committerJulian Andres Klode <jak@debian.org>2020-01-15 22:02:32 +0000
commit087c97b7959acb1f9417b0b02be58709666476dc (patch)
tree9dca81e85bb4f433dfdf6ce4f3862ef4177841ae /apt-pkg
parenta9916c3faa2b8c6fa288599efec65868d050b0ef (diff)
parent21cb4a9e513ccb6f376fbcaf67957c4851cbbe32 (diff)
Merge branch 'pu/apt-regex-cli' into 'master'
apt(8): Disable regular expressions and fnmatch See merge request apt-team/apt!95
Diffstat (limited to 'apt-pkg')
-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;