From 781e3383bd74a237737d01a2ba031b1077444615 Mon Sep 17 00:00:00 2001 From: rene Date: Thu, 14 May 2026 11:58:00 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20Karte=20l=C3=A4dt=20wieder=20+=20safe=5F?= =?UTF-8?q?media=5Fpath=20+=20Foto-L=C3=B6schung=20(SW=20by-v932)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - map.js: appState→_appState im Template, addEventListener mit ?. (kein Crash ohne Buttons) - media_utils.py: safe_media_path lstrip-Bug — 'dogs/' wurde zu 'ogs/' gekürzt; jetzt korrekte removeprefix-Logik → Altes Hundeprofil-Foto wird jetzt wirklich gelöscht --- backend/main.py | 2 +- backend/media_utils.py | 7 ++++++- backend/static/js/app.js | 2 +- backend/static/js/pages/map.js | 6 +++--- backend/static/sw.js | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/backend/main.py b/backend/main.py index c9200c5..83e7258 100644 --- a/backend/main.py +++ b/backend/main.py @@ -406,7 +406,7 @@ async def serve_media(path: str, request: _Request): raise _HE(404, "Nicht gefunden.") return _media_response(filepath) -APP_VER = "931" # muss mit APP_VER in app.js übereinstimmen +APP_VER = "932" # muss mit APP_VER in app.js übereinstimmen @app.get("/.well-known/assetlinks.json") async def assetlinks(): diff --git a/backend/media_utils.py b/backend/media_utils.py index 4cb2e28..4fa6a82 100644 --- a/backend/media_utils.py +++ b/backend/media_utils.py @@ -56,7 +56,12 @@ def safe_media_path(media_dir: str, url: str) -> str | None: Konstruiert einen sicheren Dateipfad aus einer gespeicherten URL. Gibt None zurück wenn der Pfad außerhalb von media_dir liegt (Path-Traversal-Schutz). """ - relative = url.lstrip("/media/").lstrip("/") + if url.startswith("/media/"): + relative = url[len("/media/"):] + elif url.startswith("/"): + relative = url[1:] + else: + relative = url candidate = os.path.realpath(os.path.join(media_dir, relative)) real_base = os.path.realpath(media_dir) if not candidate.startswith(real_base + os.sep) and candidate != real_base: diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 3d4f112..ba3e8b1 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '931'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '932'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.5.1'; // ← semantische Version, wird bei make release gesetzt const IS_STAGING = location.hostname === 'staging.banyaro.app'; // Cache-Bust-Parameter nach Update-Reload sofort entfernen diff --git a/backend/static/js/pages/map.js b/backend/static/js/pages/map.js index a79174f..bc65d98 100644 --- a/backend/static/js/pages/map.js +++ b/backend/static/js/pages/map.js @@ -205,7 +205,7 @@ window.Page_map = (() => {
- ${App.hasPro(appState?.user) ? ` + ${App.hasPro(_appState?.user) ? ` ` : ''} @@ -291,8 +291,8 @@ window.Page_map = (() => { }); document.getElementById('map-pin-btn').addEventListener('click', _togglePlacementMode); - document.getElementById('map-radar-btn').addEventListener('click', _toggleRadar); - document.getElementById('map-temp-btn').addEventListener('click', _toggleTemp); + document.getElementById('map-radar-btn')?.addEventListener('click', _toggleRadar); + document.getElementById('map-temp-btn')?.addEventListener('click', _toggleTemp); } // ---------------------------------------------------------- diff --git a/backend/static/sw.js b/backend/static/sw.js index bfcf946..3a62bcb 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -3,7 +3,7 @@ Offline-Cache + Push Notifications + Tile-Cache ============================================================ */ -const CACHE_VERSION = 'by-v931'; +const CACHE_VERSION = 'by-v932'; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache