1 |
When the email address of a maintainer contains unescaped |
2 |
regex-special characters (such as '+'), the maintainer-email match may |
3 |
return undesirable results. |
4 |
|
5 |
Add a command line option '--no-regex' to use re.escape() with list |
6 |
comprehension on maintainer emails when constructing the matcher |
7 |
regex. This way, an exact string match can be made rather than a regex |
8 |
match. |
9 |
--- |
10 |
bin/portageq | 10 +++++++++- |
11 |
1 file changed, 9 insertions(+), 1 deletion(-) |
12 |
|
13 |
diff --git a/bin/portageq b/bin/portageq |
14 |
index d645635..63867d3 100755 |
15 |
--- a/bin/portageq |
16 |
+++ b/bin/portageq |
17 |
@@ -1082,7 +1082,10 @@ def pquery(parser, opts, args): |
18 |
maintainer_emails = [] |
19 |
for x in opts.maintainer_email: |
20 |
maintainer_emails.extend(x.split(",")) |
21 |
- xml_matchers.append(MaintainerEmailMatcher(maintainer_emails)) |
22 |
+ if opts.no_regex: # Escape regex-special characters for an exact match |
23 |
+ xml_matchers.append(MaintainerEmailMatcher([re.escape(m) for m in maintainer_emails])) |
24 |
+ else: |
25 |
+ xml_matchers.append(MaintainerEmailMatcher(maintainer_emails)) |
26 |
if opts.orphaned: |
27 |
xml_matchers.append(match_orphaned) |
28 |
|
29 |
@@ -1240,6 +1243,11 @@ def add_pquery_arguments(parser): |
30 |
"help": "comma-separated list of maintainer email regexes to search for" |
31 |
}, |
32 |
{ |
33 |
+ "longopt": "--no-regex", |
34 |
+ "action": "store_true", |
35 |
+ "help": "Use exact matching instead of regex matching for --maintainer-email" |
36 |
+ }, |
37 |
+ { |
38 |
"longopt": "--orphaned", |
39 |
"action": "store_true", |
40 |
"help": "match only orphaned (maintainer-needed) packages" |
41 |
-- |
42 |
2.10.2 |