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