Merge pull request #747 from jnguyen32/xss-bug-fix-issue-724

XSS bug fix issue #724: XSS issue when importing through getHTML() function
This commit is contained in:
Philipp Kühn 2020-07-08 08:57:14 +02:00 committed by GitHub
commit aac9e7d674
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20574 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.history
.DS_Store .DS_Store
node_modules node_modules
dist/ dist/

20570
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -272,9 +272,9 @@ export default class Editor extends Emitter {
} }
if (typeof content === 'string') { if (typeof content === 'string') {
const element = document.createElement('div') const htmlString = `<div>${content}</div>`;
element.innerHTML = content.trim() const parser = new window.DOMParser;
const element = parser.parseFromString(htmlString, "text/html").body;
return DOMParser.fromSchema(this.schema).parse(element, parseOptions) return DOMParser.fromSchema(this.schema).parse(element, parseOptions)
} }