mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
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).
This commit is contained in:
parent
3805d7f308
commit
c09adffb64
1 changed files with 3 additions and 2 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue