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

fix(pagebuilder): Html content type unescapes when GraphQL does not #2283

Merged
Merged
Changes from 1 commit
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
21 changes: 16 additions & 5 deletions packages/pagebuilder/lib/ContentTypes/Html/configAggregator.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import { getAdvanced } from '../../utils';

export default node => {
const dom = new DOMParser().parseFromString(
'<!doctype html><body>' + node.textContent,
'text/html'
);
let html;
if (node.dataset.decoded) {
html = node.innerHTML;
if (process.env.NODE_ENV !== 'production') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we remove logs in production bundles anyways - shouldn't need to gate with a condition. If I'm wrong we probably have to go clean up our app :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might, but I just wanted to be explicit. This is a pattern we ought to follow. We may later remove the drop_console in some cases!

console.warn(
'PageBuilder HTML content was unescaped! This may be a Magento configuration error.'
);
}
} else {
const dom = new DOMParser().parseFromString(
'<!doctype html><body>' + node.textContent,
'text/html'
);
html = dom.body.innerHTML;
}
return {
html: dom.body.innerHTML,
html,
...getAdvanced(node)
};
};