-
Notifications
You must be signed in to change notification settings - Fork 683
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pagebuilder): Html content type unescapes content when GraphQL do…
…es not
- Loading branch information
James Zetlen
committed
Mar 25, 2020
1 parent
becd5e2
commit 1bee42d
Showing
1 changed file
with
16 additions
and
5 deletions.
There are no files selected for viewing
21 changes: 16 additions & 5 deletions
21
packages/pagebuilder/lib/ContentTypes/Html/configAggregator.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') { | ||
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) | ||
}; | ||
}; |