Make extended_cp_match() use re.escape() for safety, and since the result is
authorZac Medico <zmedico@gentoo.org>
Sun, 25 Jul 2010 21:59:56 +0000 (14:59 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 25 Jul 2010 21:59:56 +0000 (14:59 -0700)
cached here anyway.

pym/portage/dep/__init__.py

index 9720a510e609a4b85fb8593d7540f5e92d31c0fe..a8c647cee31e410bb0a205a6f04e4bafbcf86997 100644 (file)
@@ -765,8 +765,8 @@ def extended_cp_match(extended_cp, other_cp):
        global _extended_cp_re_cache
        extended_cp_re = _extended_cp_re_cache.get(extended_cp)
        if extended_cp_re is None:
-               extended_cp_re = re.compile("^" + extended_cp.replace(
-                       "+", r"\+").replace(".", r"\.").replace('*', '[^/]*') + "$")
+               extended_cp_re = re.compile("^" + re.escape(extended_cp).replace(
+                       r'\*', '[^/]*') + "$")
                _extended_cp_re_cache[extended_cp] = extended_cp_re
        return extended_cp_re.match(other_cp) is not None