Emulate fullmatch with match

re.fullmatch was introduced in Python 3.4
This commit is contained in:
Unrud 2016-09-02 15:06:32 +02:00
parent 11df2f1184
commit 9e27d4e2a8

View File

@ -134,10 +134,12 @@ class Rights(BaseRights):
self.logger.debug(
"Test if '%s:%s' matches against '%s:%s' from section '%s'",
user, sane_path, re_user, re_collection, section)
user_match = re.fullmatch(re_user, user)
# Emulate fullmatch
user_match = re.match(r"(?:%s)\Z" % re_user, user)
if user_match:
re_collection = re_collection.format(*user_match.groups())
if re.fullmatch(re_collection, sane_path):
# Emulate fullmatch
if re.match(r"(?:%s)\Z" % re_collection, sane_path):
self.logger.debug("Section '%s' matches", section)
return permission in regex.get(section, "permission")
else: