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.
---
 bin/portageq | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/bin/portageq b/bin/portageq
index d645635..63867d3 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -1082,7 +1082,10 @@ def pquery(parser, opts, args):
                maintainer_emails = []
                for x in opts.maintainer_email:
                        maintainer_emails.extend(x.split(","))
-               xml_matchers.append(MaintainerEmailMatcher(maintainer_emails))
+               if opts.no_regex: # Escape regex-special characters for an 
exact match
+                       
xml_matchers.append(MaintainerEmailMatcher([re.escape(m) for m in 
maintainer_emails]))
+               else:
+                       
xml_matchers.append(MaintainerEmailMatcher(maintainer_emails))
        if opts.orphaned:
                xml_matchers.append(match_orphaned)
 
@@ -1240,6 +1243,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"
-- 
2.10.2


Reply via email to