From 48f22a7787fd10d79c015fffa21c9e2a596a0679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Tue, 3 Nov 2026 09:22:39 +0100 Subject: [PATCH] fix: n8n's JSON-LD endpoint only overwrites plain html content elements PUT /api/json-ld/{uid} replaced the bodytext of any content element, so a wrong uid in n8n could wipe visible page content (text, plugins, ...). Elements of any other CType than html are now refused with 409 before anything is written. The group's "Explicitly allow tt_content:CType:html" does not guard this on its own, since the endpoint bypasses DataHandler's record access checks. Co-Authored-By: Claude Opus 5.5 --- docs/cms-api.md | 9 +++++---- packages/ep_products/Classes/JsonLd/JsonLdApi.php | 14 +++++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/docs/cms-api.md b/docs/cms-api.md index c28122c..67bbfb4 100644 --- a/docs/cms-api.md +++ b/docs/cms-api.md @@ -104,8 +104,9 @@ Configuration (extension configuration `ep_products`, tab ContentFeed): `content n8n writes the JSON-LD (SEO markup) of a content element (`EP\EpProducts\JsonLd\JsonLdApi`). n8n is the source of truth: the element's `bodytext` is replaced with the posted object wrapped in -`" inside a value must not end the script element private const int JSON_FLAGS = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_THROW_ON_ERROR; @@ -46,13 +50,17 @@ class JsonLdApi $uid = substr($request->getUri()->getPath(), strlen(self::PATH_PREFIX)); $record = 1 === preg_match('/^[1-9]\d*$/', $uid) - ? BackendUtility::getRecord('tt_content', (int) $uid, 'uid,pid,bodytext') + ? BackendUtility::getRecord('tt_content', (int) $uid, 'uid,pid,CType,bodytext') : null; if (null === $record) { return new JsonResponse(['message' => 'Content element not found'], 404); } + if (self::CTYPE !== $record['CType']) { + return new JsonResponse(['message' => 'Content element is of type "' . $record['CType'] . '", only "' . self::CTYPE . '" is written'], 409); + } + try { // Decoded as objects, not arrays, so an empty {} stays an object $jsonLd = json_decode((string) $request->getBody(), false, 512, JSON_THROW_ON_ERROR);