This commit is contained in:
Jürgen Mummert
2025-12-25 15:01:20 +01:00
parent 08c1f8a015
commit 497b46f113
+17 -5
View File
@@ -84,12 +84,24 @@ class PdfIndexService
* ===================================================== */ * ===================================================== */
private function normalizePdfUrl(string $url): ?string private function normalizePdfUrl(string $url): ?string
{ {
$url = html_entity_decode($url); // Fall 1: direkter /files/-Pfad
if (str_starts_with($url, '/files/') && str_ends_with($url, '.pdf')) {
return $url;
}
// direkter /files/*.pdf-Link // Fall 2: Contao-Download-Link mit ?p=
$path = parse_url($url, PHP_URL_PATH); $decoded = html_entity_decode($url);
if ($path && preg_match('~^/files/.*\.pdf$~i', $path)) {
return $path; $parts = parse_url($decoded);
if (!isset($parts['query'])) {
return null;
}
parse_str($parts['query'], $query);
if (!empty($query['p'])) {
// Contao speichert Pfade relativ zu /files
return '/files/' . ltrim($query['p'], '/');
} }
return null; return null;