mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 03:42:37 +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 pathlib import Path
|
||||||
from smtplib import SMTPException
|
from smtplib import SMTPException
|
||||||
from urllib.error import HTTPError, URLError
|
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 urllib.request import Request, build_opener
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -403,13 +403,14 @@ class AjaxProxy(View):
|
||||||
ttl = None
|
ttl = None
|
||||||
if getattr(settings, "UMAP_XSENDFILE_HEADER", None):
|
if getattr(settings, "UMAP_XSENDFILE_HEADER", None):
|
||||||
response = HttpResponse()
|
response = HttpResponse()
|
||||||
response[settings.UMAP_XSENDFILE_HEADER] = f"/proxy/{quote(url)}"
|
response[settings.UMAP_XSENDFILE_HEADER] = f"/proxy/{quote_plus(url)}"
|
||||||
if ttl:
|
if ttl:
|
||||||
response["X-Accel-Expires"] = ttl
|
response["X-Accel-Expires"] = ttl
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# You should not use this in production (use Nginx or so)
|
# You should not use this in production (use Nginx or so)
|
||||||
headers = {"User-Agent": "uMapProxy +http://wiki.openstreetmap.org/wiki/UMap"}
|
headers = {"User-Agent": "uMapProxy +http://wiki.openstreetmap.org/wiki/UMap"}
|
||||||
|
url = url.replace(" ", "+")
|
||||||
request = Request(url, headers=headers)
|
request = Request(url, headers=headers)
|
||||||
opener = build_opener()
|
opener = build_opener()
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue