Merge pull request #457 from mouse-reeve/post-error

Fixes server error posting status
This commit is contained in:
Mouse Reeve 2021-01-01 07:32:37 -08:00 committed by GitHub
commit a0ffac8a78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View file

@ -41,6 +41,9 @@ def handle_remote_webfinger(query):
user = None
# usernames could be @user@domain or user@domain
if not query:
return None
if query[0] == '@':
query = query[1:]
@ -218,7 +221,7 @@ def handle_status(user, form):
# inspect the text for user tags
matches = []
for match in re.finditer(regex.username, status.content):
for match in re.finditer(regex.strict_username, status.content):
username = match.group().strip().split('@')[1:]
if len(username) == 1:
# this looks like a local user (@user), fill in the domain

View file

@ -2,5 +2,7 @@
domain = r'[a-z-A-Z0-9_\-]+\.[a-z]+'
localname = r'@?[a-zA-Z_\-\.0-9]+'
strict_localname = r'@[a-zA-Z_\-\.0-9]+'
username = r'%s(@%s)?' % (localname, domain)
strict_username = r'%s(@%s)?' % (strict_localname, domain)
full_username = r'%s@%s' % (localname, domain)

View file

@ -593,14 +593,14 @@ def tag(request):
def untag(request):
''' untag a book '''
name = request.POST.get('name')
tag = get_object_or_404(models.Tag, name=name)
tag_obj = get_object_or_404(models.Tag, name=name)
book_id = request.POST.get('book')
book = get_object_or_404(models.Edition, id=book_id)
tag = get_object_or_404(
models.UserTag, tag=tag, book=book, user=request.user)
tag_activity = tag.to_remove_activity(request.user)
tag.delete()
user_tag = get_object_or_404(
models.UserTag, tag=tag_obj, book=book, user=request.user)
tag_activity = user_tag.to_remove_activity(request.user)
user_tag.delete()
broadcast(request.user, tag_activity)
return redirect('/book/%s' % book_id)