From 693306c03c9fe8b97d44a5e73747a6b26e3dd086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Mummert?= Date: Thu, 25 Dec 2025 14:31:47 +0100 Subject: [PATCH] Bugfix --- src/Service/PdfIndexService.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Service/PdfIndexService.php b/src/Service/PdfIndexService.php index 062b4db..9f2f6c6 100644 --- a/src/Service/PdfIndexService.php +++ b/src/Service/PdfIndexService.php @@ -131,11 +131,13 @@ class PdfIndexService { $url = html_entity_decode($url); + // 1) direkter Pfad /files/xyz.pdf $path = parse_url($url, PHP_URL_PATH); if ($path && str_ends_with(strtolower($path), '.pdf')) { return $path; } + // 2) Query-Parameter auswerten $query = parse_url($url, PHP_URL_QUERY); if (!$query) { return null; @@ -143,16 +145,18 @@ class PdfIndexService parse_str($query, $params); - if (empty($params['p'])) { - return null; + // 2a) Contao: p=pdf/xyz.pdf + if (!empty($params['p']) && str_ends_with(strtolower($params['p']), '.pdf')) { + return '/files/' . ltrim($params['p'], '/'); } - $p = ltrim($params['p'], '/'); - if (!str_ends_with(strtolower($p), '.pdf')) { - return null; + // 2b) Contao: f=xyz.pdf (typischer Download-Link) + if (!empty($params['f']) && str_ends_with(strtolower($params['f']), '.pdf')) { + // Standard: PDFs liegen unter /files/pdf/ + return '/files/pdf/' . ltrim($params['f'], '/'); } - return '/files/' . $p; + return null; } private function getAbsolutePath(string $url): ?string