Merge pull request #9 from OHTU-German-learning-website/master

pull changes to my branch
This commit is contained in:
erzabytyci
2026-05-19 13:22:00 +03:00
committed by GitHub
3 changed files with 10 additions and 2 deletions
@@ -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';
@@ -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) {
@@ -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 ? (
<p {...attributes}>{children}</p>
@@ -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 <div className="rendered-html">{parsedContent}</div>;
}