diff --git a/bookwyrm/models/user.py b/bookwyrm/models/user.py index 4cbe387f4..afba0b3a0 100644 --- a/bookwyrm/models/user.py +++ b/bookwyrm/models/user.py @@ -170,6 +170,7 @@ class User(OrderedCollectionPageMixin, AbstractUser): def save(self, *args, **kwargs): ''' populate fields for new local users ''' # this user already exists, no need to populate fields + print(self.username) if not self.local and not re.match(regex.full_username, self.username): # generate a username that uses the domain (webfinger format) actor_parts = urlparse(self.remote_id) diff --git a/bookwyrm/utils/regex.py b/bookwyrm/utils/regex.py index b087b5649..c818bc415 100644 --- a/bookwyrm/utils/regex.py +++ b/bookwyrm/utils/regex.py @@ -1,10 +1,10 @@ ''' defining regexes for regularly used concepts ''' domain = r'[\w_\-\.]+\.[a-z]{2,}' -localname = r'@?[a-zA-Z_\-\.0-9]+\b' +localname = r'@?[a-zA-Z_\-\.0-9]+' strict_localname = r'@[a-zA-Z_\-\.0-9]+' username = r'%s(@%s)?' % (localname, domain) strict_username = r'\B%s(@%s)?\b' % (strict_localname, domain) -full_username = r'\B%s@%s\b' % (localname, domain) +full_username = r'%s@%s\b' % (localname, domain) # should match (BookWyrm/1.0.0; or (BookWyrm/99.1.2; bookwyrm_user_agent = r'\(BookWyrm/[0-9]+\.[0-9]+\.[0-9]+;' diff --git a/bookwyrm/views.py b/bookwyrm/views.py index f1851da84..5c5934ddb 100644 --- a/bookwyrm/views.py +++ b/bookwyrm/views.py @@ -265,7 +265,7 @@ def search(request): return JsonResponse([r.json() for r in book_results], safe=False) # use webfinger for mastodon style account@domain.com username - if re.match(regex.full_username, query): + if re.match(r'\B%s' % regex.full_username, query): outgoing.handle_remote_webfinger(query) # do a local user search