From 0de1b8d0c39c85ffa015f1d8d6824685b38286ad Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 8 Apr 2021 09:59:21 -0700 Subject: [PATCH] Case insensitive remote user search --- bookwyrm/tests/views/test_helpers.py | 3 +++ bookwyrm/views/helpers.py | 2 +- bookwyrm/views/search.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bookwyrm/tests/views/test_helpers.py b/bookwyrm/tests/views/test_helpers.py index c646b4b4..7d2bc42c 100644 --- a/bookwyrm/tests/views/test_helpers.py +++ b/bookwyrm/tests/views/test_helpers.py @@ -112,6 +112,9 @@ class ViewsHelpers(TestCase): result = views.helpers.handle_remote_webfinger("mouse@local.com") self.assertEqual(result, self.local_user) + result = views.helpers.handle_remote_webfinger("mOuSe@loCal.cOm") + self.assertEqual(result, self.local_user) + @responses.activate def test_load_user(self, _): """ find a remote user using webfinger """ diff --git a/bookwyrm/views/helpers.py b/bookwyrm/views/helpers.py index 41e6a608..2b6501ff 100644 --- a/bookwyrm/views/helpers.py +++ b/bookwyrm/views/helpers.py @@ -124,7 +124,7 @@ def handle_remote_webfinger(query): return None try: - user = models.User.objects.get(username=query) + user = models.User.objects.get(username__iexact=query) except models.User.DoesNotExist: url = "https://%s/.well-known/webfinger?resource=acct:%s" % (domain, query) try: diff --git a/bookwyrm/views/search.py b/bookwyrm/views/search.py index 28f393c8..9e7df9f4 100644 --- a/bookwyrm/views/search.py +++ b/bookwyrm/views/search.py @@ -34,7 +34,7 @@ class Search(View): if query and re.match(regex.full_username, query): handle_remote_webfinger(query) - # do a user search + # do a user search user_results = ( models.User.viewer_aware_objects(request.user) .annotate(