aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2023-11-10 22:11:36 +0100
committerDaniel Schadt <kingdread@gmx.de>2023-11-10 22:11:36 +0100
commit40779bcfea8fce9a23c552cf449d25a0971ee329 (patch)
tree3e6e42758c0928d791848e3cb6a7d2789abbd3d0
parenta6b724b2f52923171b829a7a2c9f5902857f8fbf (diff)
downloadfietsboek-40779bcfea8fce9a23c552cf449d25a0971ee329.tar.gz
fietsboek-40779bcfea8fce9a23c552cf449d25a0971ee329.tar.bz2
fietsboek-40779bcfea8fce9a23c552cf449d25a0971ee329.zip
fix wrong tile URL being requested
This was a leftover from the pydantic migration, which now uses a custom URL type that is no longer just an "alias" for str. Therefore, the {x} placeholders got escaped, which we now need to revert. I'm not super happy with the way this works, but it works so far I guess.
-rw-r--r--fietsboek/views/tileproxy.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/fietsboek/views/tileproxy.py b/fietsboek/views/tileproxy.py
index 999b04f..0264284 100644
--- a/fietsboek/views/tileproxy.py
+++ b/fietsboek/views/tileproxy.py
@@ -8,10 +8,10 @@ Additionally, this protects the users' IP, as only fietsboek can see it.
"""
import datetime
import logging
-import random
import threading
from itertools import chain
from typing import List, Optional
+from urllib.parse import quote
import requests
from pydantic import AnyUrl, TypeAdapter
@@ -331,7 +331,13 @@ def tile_proxy(request):
LOGGER.debug("Aborted attempt to contact %s due to previous timeouts", provider)
raise HTTPGatewayTimeout(f"Avoiding request to {provider}")
- url = tile_sources[provider].url.unicode_string().format(x=x, y=y, z=z, s=random.choice("abc"))
+ url = (
+ tile_sources[provider]
+ .url.unicode_string()
+ .replace(quote("{x}"), str(x))
+ .replace(quote("{y}"), str(y))
+ .replace(quote("{z}"), str(z))
+ )
# Avoid doing actual requests during tests
if url.startswith("http://localhost:0"):
LOGGER.debug("Skipping tile proxy request for testing URL")