Skip to content

Commit

Permalink
PWA-3401::Update DOM Text Interpreted As HTML in PWA Code where ever …
Browse files Browse the repository at this point in the history
…it is needed
  • Loading branch information
glo82145 committed Jan 15, 2025
1 parent b3a46c6 commit 9cf4d4d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
10 changes: 9 additions & 1 deletion packages/pagebuilder/lib/ContentTypes/Block/configAggregator.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import DOMPurify from 'dompurify';
import { getAdvanced } from '../../utils';

export default node => {
// Get the raw HTML content from the first child node
const rawHTML = node.childNodes[0] ? node.childNodes[0].innerHTML : '';

// Sanitize the raw HTML using DOMPurify
const sanitizedHTML = DOMPurify.sanitize(rawHTML);

return {
richContent: node.childNodes[0] ? node.childNodes[0].innerHTML : '',
// Return the sanitized HTML content, along with the result from getAdvanced
richContent: sanitizedHTML,
...getAdvanced(node)
};
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`returns concatenated error message when allowErrorMessages 1`] = `"GraphQL Error 1, GraphQL Error 2"`;
exports[`returns concatenated error message when allowErrorMessages 1`] = `"formError.responseError"`;

exports[`returns general error message 1`] = `"formError.errorMessage, Generic Error"`;
exports[`returns general error message 1`] = `"formError.responseError, Generic Error"`;
5 changes: 4 additions & 1 deletion venia-integration-tests/src/fixtures/googleMapApi/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import DOMPurify from 'dompurify';
export const createGoogleMapApi = currentMapApi => {
return {
maps: {
Expand Down Expand Up @@ -85,7 +86,9 @@ export const createGoogleMapApi = currentMapApi => {

open(map) {
map.infoWindowContainer.style.maxWidth = this.maxWidth;
map.infoWindowContainer.innerHTML = this.content;
map.infoWindowContainer.innerHTML = DOMPurify.sanitize(
this.content
);
}

close() {
Expand Down

0 comments on commit 9cf4d4d

Please sign in to comment.