Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pwa 3401::https://jira.corp.adobe.com/browse/PWA-3401 #4374

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"caniuse-lite": "~1.0.30001335",
"path-to-regexp": "^8.2.0",
"qs": "^6.13.0",
"setimmediate": "^1.0.5"
"setimmediate": "^1.0.5",
"dompurify": "^2.3.8"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "~7.4.4",
Expand Down
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"`;
4 changes: 2 additions & 2 deletions packages/peregrine/lib/util/htmlStringImgUrlConverter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import makeUrl from './makeUrl';
import resolveLinkProps from './resolveLinkProps';

import DOMPurify from 'dompurify';
/**
* Modifies html string images to use makeUrl as source and resolves links to use internal path.
*
Expand All @@ -9,7 +9,7 @@ import resolveLinkProps from './resolveLinkProps';
*/
const htmlStringImgUrlConverter = htmlString => {
const temporaryElement = document.createElement('div');
temporaryElement.innerHTML = htmlString;
temporaryElement.innerHTML = DOMPurify.sanitize(htmlString);
for (const imgElement of temporaryElement.getElementsByTagName('img')) {
imgElement.src = makeUrl(imgElement.src, {
type: 'image-wysiwyg',
Expand Down
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
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8935,6 +8935,11 @@ domhandler@^4.0.0, domhandler@^4.2.0, domhandler@^4.3.1:
dependencies:
domelementtype "^2.2.0"

dompurify@^2.3.8:
version "2.5.8"
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.5.8.tgz#2809d89d7e528dc7a071dea440d7376df676f824"
integrity sha512-o1vSNgrmYMQObbSSvF/1brBYEQPHhV1+gsmrusO7/GXtp1T9rCS8cXFqVxK/9crT1jA6Ccv+5MTSjBNqr7Sovw==

domutils@^2.5.2, domutils@^2.8.0:
version "2.8.0"
resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.8.0.tgz#4437def5db6e2d1f5d6ee859bd95ca7d02048135"
Expand Down
Loading