From c09adffb64755736797bd176121a913e69ef0d7b Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Wed, 26 Jun 2024 22:56:32 +0200 Subject: [PATCH] fix: make sure to quote spaces in URL when using proxy space is a control character, and thus is forbidden in an URL, and we do have spaces in overpass URL (containing raw queries). --- umap/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/umap/views.py b/umap/views.py index 7830d373..bc3e6655 100644 --- a/umap/views.py +++ b/umap/views.py @@ -11,7 +11,7 @@ from io import BytesIO from pathlib import Path from smtplib import SMTPException from urllib.error import HTTPError, URLError -from urllib.parse import quote, quote_plus, urlparse +from urllib.parse import quote_plus, urlparse from urllib.request import Request, build_opener from django.conf import settings @@ -403,13 +403,14 @@ class AjaxProxy(View): ttl = None if getattr(settings, "UMAP_XSENDFILE_HEADER", None): response = HttpResponse() - response[settings.UMAP_XSENDFILE_HEADER] = f"/proxy/{quote(url)}" + response[settings.UMAP_XSENDFILE_HEADER] = f"/proxy/{quote_plus(url)}" if ttl: response["X-Accel-Expires"] = ttl return response # You should not use this in production (use Nginx or so) headers = {"User-Agent": "uMapProxy +http://wiki.openstreetmap.org/wiki/UMap"} + url = url.replace(" ", "+") request = Request(url, headers=headers) opener = build_opener() try: