mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-30 13:31:08 +00:00
Fixes username regex
This commit is contained in:
parent
03a5f333e1
commit
54f27519df
3 changed files with 4 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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]+;'
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue