commit:     aa57d60d9c77a46f542475dcf448c83af40e73e1
Author:     Göktürk Yüksek <gokturk <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 30 21:43:02 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Dec 31 21:41:35 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=aa57d60d

portageq: allow disabling regex matching of maintainer emails #604164

When the email address of a maintainer contains unescaped
regex-special characters (such as '+'), the maintainer-email match may
return undesirable results.

Add a command line option '--no-regex' to use re.escape() with list
comprehension on maintainer emails when constructing the matcher
regex. This way, an exact string match can be made rather than a regex
match.

X-Gentoo-bug: 604164
X-Gentoo-bug-url: https://bugs.gentoo.org/604164

 bin/portageq | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/bin/portageq b/bin/portageq
index d645635..06c8e0e 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -1082,6 +1082,8 @@ def pquery(parser, opts, args):
                maintainer_emails = []
                for x in opts.maintainer_email:
                        maintainer_emails.extend(x.split(","))
+               if opts.no_regex: # Escape regex-special characters for an 
exact match
+                       maintainer_emails = [re.escape(x) for x in 
maintainer_emails]
                xml_matchers.append(MaintainerEmailMatcher(maintainer_emails))
        if opts.orphaned:
                xml_matchers.append(match_orphaned)
@@ -1240,6 +1242,11 @@ def add_pquery_arguments(parser):
                                        "help": "comma-separated list of 
maintainer email regexes to search for"
                                },
                                {
+                                       "longopt": "--no-regex",
+                                       "action": "store_true",
+                                       "help": "Use exact matching instead of 
regex matching for --maintainer-email"
+                               },
+                               {
                                        "longopt": "--orphaned",
                                        "action": "store_true",
                                        "help": "match only orphaned 
(maintainer-needed) packages"

Reply via email to