Skip to content

Commit

Permalink
Merge pull request #1788 from MTG/iss1787
Browse files Browse the repository at this point in the history
Add urlquote to username filters in search links
  • Loading branch information
ffont authored Oct 7, 2024
2 parents e2b8822 + 186896f commit 7d406e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

import datetime
import os
import pytz
import random

import pytz
from django.conf import settings
from django.contrib.admin.utils import NestedObjects
from django.contrib.auth.models import User
Expand All @@ -37,6 +37,7 @@
from django.templatetags.static import static
from django.urls import reverse
from django.utils.encoding import smart_str
from django.utils.http import urlquote
from django.utils.timezone import now
from psycopg2.errors import ForeignKeyViolation

Expand Down Expand Up @@ -223,10 +224,10 @@ def get_absolute_url(self):
return reverse('account', args=[smart_str(self.user.username)])

def get_user_sounds_in_search_url(self):
return f'{reverse("sounds-search")}?f=username:"{ self.user.username }"&s=Date+added+(newest+first)&g=0'
return f'{reverse("sounds-search")}?f=username:"{ urlquote(self.user.username) }"&s=Date+added+(newest+first)&g=0'

def get_user_packs_in_search_url(self):
return f'{reverse("sounds-search")}?f=username:"{ self.user.username }"&s=Date+added+(newest+first)&g=1&dp=1'
return f'{reverse("sounds-search")}?f=username:"{ urlquote(self.user.username) }"&s=Date+added+(newest+first)&g=1&dp=1'

def get_latest_packs_for_profile_page(self):
latest_pack_ids = Pack.objects.select_related().filter(user=self.user, num_sounds__gt=0).exclude(is_deleted=True) \
Expand Down
3 changes: 2 additions & 1 deletion geotags/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from django.http import Http404, HttpResponse
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from django.utils.http import urlquote
from django.views.decorators.cache import cache_page
from django.views.decorators.clickjacking import xframe_options_exempt
from accounts.models import Profile
Expand Down Expand Up @@ -210,7 +211,7 @@ def for_user(request, username):
'pack': None,
'sound': None,
'url': reverse('geotags-for-user-barray', args=[username]),
'query_search_page_url': reverse('sounds-search') + f'?f=username:{username}&mm=1'
'query_search_page_url': reverse('sounds-search') + f'?f=username:{urlquote(username)}&mm=1'
})
return render(request, 'geotags/geotags.html', tvars)

Expand Down

0 comments on commit 7d406e8

Please sign in to comment.