fix: Force configuration for SafeMarkdown component in Handlebars (#22417)

This commit is contained in:
Geido 2022-12-14 22:23:34 +01:00 committed by GitHub
parent 90d79c78d2
commit ebaa94974b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -34,6 +34,13 @@ export const HandlebarsViewer = ({
}: HandlebarsViewerProps) => {
const [renderedTemplate, setRenderedTemplate] = useState('');
const [error, setError] = useState('');
const appContainer = document.getElementById('app');
const { common } = JSON.parse(
appContainer?.getAttribute('data-bootstrap') || '{}',
);
const htmlSanitization = common?.conf?.HTML_SANITIZATION ?? true;
const htmlSchemaOverrides =
common?.conf?.HTML_SANITIZATION_SCHEMA_EXTENSIONS || {};
useMemo(() => {
try {
@ -56,7 +63,13 @@ export const HandlebarsViewer = ({
}
if (renderedTemplate) {
return <SafeMarkdown source={renderedTemplate} />;
return (
<SafeMarkdown
source={renderedTemplate}
htmlSanitization={htmlSanitization}
htmlSchemaOverrides={htmlSchemaOverrides}
/>
);
}
return <p>Loading...</p>;
};