From 9564ea515f64c2f93faf5b01348075b6a75ca329 Mon Sep 17 00:00:00 2001 From: Eric Bus Date: Mon, 23 Nov 2026 18:01:18 +0100 Subject: [PATCH] fix: double-encoded '&' in headers of static pages The API returns the headers of static pages (statisch/...) HTML-escaped twice, so '&' from the intranet editor showed as '&' on the site (e.g. 'GOOI&meer Radio' on /frequenties). Undo the second encoding for static page and contact page content until the API is fixed. Co-Authored-By: Claude Opus 5.5 --- app/Http/Controllers/ContactController.php | 3 +++ app/Http/Controllers/Controller.php | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php index db3697ef..f58881d4 100644 --- a/app/Http/Controllers/ContactController.php +++ b/app/Http/Controllers/ContactController.php @@ -21,6 +21,9 @@ class ContactController extends Controller if ($page->edited) { $page->edited = Controller::JsonToDateTime($page->edited); } + if (isset($page->content) && is_string($page->content)) { + $page->content = Controller::fixDoubleEncodedEntities($page->content); + } return view('contact', ['page' => $page]); } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 4627acbb..bd2fe127 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -240,7 +240,22 @@ class Controller extends BaseController if (isset($page->edited) && $page->edited) { $page->edited = Controller::JsonToDateTime($page->edited); } + if (isset($page->content) && is_string($page->content)) { + $page->content = self::fixDoubleEncodedEntities($page->content); + } return view('static', compact('page')); } + + /** + * The API returns headers of static pages HTML-escaped twice, so an '&' + * typed in the intranet editor shows up as '&' on the site + * (e.g. '

GOOI&meer Radio

'). Undo that second encoding: + * '&' -> '&', ''' -> ''', etc. + * Can be removed once the API is fixed. + */ + public static function fixDoubleEncodedEntities($html) + { + return preg_replace('/&(#[0-9]+|#x[0-9a-f]+|[a-z][a-z0-9]*);/i', '&$1;', $html); + } }