Re: [gentoo-portage-dev] [PATCH v1] portageq: escape regex-special characters in maintainer emails #604164

2016-12-30 Thread Zac Medico
On 12/30/2016 10:02 AM, Göktürk Yüksek wrote:
> When the email address of a maintainer contains regex-special
> characters (such as '+'), re.match() returns incorrect results. Use
> re.escape() with list comprehension on maintainer emails when
> constructing the matcher regex.

I've commented on bug 604164 that we should add a new option rather than
drop regex support from the existing option.
-- 
Thanks,
Zac



[gentoo-portage-dev] [PATCH v1] portageq: escape regex-special characters in maintainer emails #604164

2016-12-30 Thread Göktürk Yüksek
When the email address of a maintainer contains regex-special
characters (such as '+'), re.match() returns incorrect results. Use
re.escape() with list comprehension on maintainer emails when
constructing the matcher regex.
---
 bin/portageq | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/portageq b/bin/portageq
index d645635..376cb2b 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -1009,7 +1009,7 @@ list_preserved_libs.__doc__ = 
docstrings['list_preserved_libs']
 
 class MaintainerEmailMatcher(object):
def __init__(self, maintainer_emails):
-   self._re = re.compile("^(%s)$" % "|".join(maintainer_emails), 
re.I)
+   self._re = re.compile("^(%s)$" % "|".join([re.escape(m) for m 
in maintainer_emails]), re.I)
 
def __call__(self, metadata_xml):
match = False
-- 
2.10.2