diff --git a/gradesa/data/migrations/00045_fix_impressum_style_attribute.sql b/gradesa/data/migrations/00045_fix_impressum_style_attribute.sql new file mode 100644 index 0000000..71ce679 --- /dev/null +++ b/gradesa/data/migrations/00045_fix_impressum_style_attribute.sql @@ -0,0 +1,4 @@ +-- Remove empty style attribute that caused React errors on the Impressum page +UPDATE html_pages +SET content = REPLACE(content, 'style=""', '') +WHERE page_group = 'system' AND slug = 'impressum'; diff --git a/gradesa/src/app/api/pages/[type]/[slug]/route.js b/gradesa/src/app/api/pages/[type]/[slug]/route.js index b157366..33dd5c0 100644 --- a/gradesa/src/app/api/pages/[type]/[slug]/route.js +++ b/gradesa/src/app/api/pages/[type]/[slug]/route.js @@ -98,7 +98,7 @@ function sanitize(data) { const window = new JSDOM("").window; const purify = DOMPurify(window); const cleaned = purify.sanitize(data, { ADD_ATTR: ["target"] }); - return cleaned; + return cleaned.replace(/\s+style=""/g, ""); } async function slugIsInUse(type, slug) { diff --git a/gradesa/src/components/ui/render-html/render-html.jsx b/gradesa/src/components/ui/render-html/render-html.jsx index a6ff947..e7a5d0e 100644 --- a/gradesa/src/components/ui/render-html/render-html.jsx +++ b/gradesa/src/components/ui/render-html/render-html.jsx @@ -63,6 +63,10 @@ const prefixRootRelativePath = (value) => { export default function RenderHTML({ data, disableGlossary = false }) { if (!data) return null; + // Strip empty style attributes before parsing so React does not receive + // an invalid string value for the style prop. + const cleanedData = data.replace(/\s+style=""/g, ""); + const renderParagraph = (attributes, children) => disableGlossary ? (
{children}
@@ -135,6 +139,6 @@ export default function RenderHTML({ data, disableGlossary = false }) { return handler ? handler(normalizedAttributes, children) : undefined; }; - const parsedContent = parse(data, { replace: replacer }); + const parsedContent = parse(cleanedData, { replace: replacer }); return