From 0f447026400604df253f1a94f100551a6f9f9015 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 8 Jan 2024 11:18:29 +0100 Subject: [PATCH] Geo coding: Use always-ascii cache keys --- src/pretix/control/views/geo.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pretix/control/views/geo.py b/src/pretix/control/views/geo.py index a69fb6b4f..8f4aa8973 100644 --- a/src/pretix/control/views/geo.py +++ b/src/pretix/control/views/geo.py @@ -19,6 +19,7 @@ # You should have received a copy of the GNU Affero General Public License along with this program. If not, see # . # +import hashlib import logging from urllib.parse import quote @@ -36,7 +37,8 @@ logger = logging.getLogger(__name__) class GeoCodeView(LoginRequiredMixin, View): def get(self, request, *args, **kwargs): q = self.request.GET.get('q') - cd = cache.get('geocode:{}'.format(q)) + cache_key = 'geocode:{}'.format(hashlib.sha256(q.encode()).hexdigest()) + cd = cache.get(cache_key) if cd: return JsonResponse({ 'success': True, @@ -61,7 +63,7 @@ class GeoCodeView(LoginRequiredMixin, View): 'results': [] }, status=200) - cache.set('geocode:{}'.format(q), res, timeout=3600 * 6) + cache.set(cache_key, res, timeout=3600 * 6) return JsonResponse({ 'success': True, 'results': res