You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2020/08/24 21:22:06 UTC

[allura] 03/03: [#8375] handle regex escape differences, which fixes a few tests

This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8375
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 6973f36c737b727557754a50a4e2ca3198a328c9
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Mon Aug 24 17:21:50 2020 -0400

    [#8375] handle regex escape differences, which fixes a few tests
---
 Allura/allura/lib/plugin.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 821a3f6..b67abdc 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -559,7 +559,8 @@ class LocalAuthenticationProvider(AuthenticationProvider):
     def by_username(self, username):
         from allura import model as M
         un = re.escape(username)
-        un = un.replace(r'\_', '[-_]')
+        escaped_underscore = re.escape('_')  # changes in py3.x versions # https://docs.python.org/3/library/re.html#re.escape
+        un = un.replace(escaped_underscore, '[-_]')
         un = un.replace(r'\-', '[-_]')
         rex = re.compile('^' + un + '$')
         return M.User.query.get(username=rex, disabled=False, pending=False)