mirror of
https://github.com/OHTU-German-learning-website/OHTU-German-learning-website.git
synced 2026-10-12 19:13:51 +03:00
Merge pull request #517 from OHTU-German-learning-website/glossary
Fix empty style attr handling for Impressum
This commit is contained in:
@@ -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>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user