Skip to content
Closed
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
5 changes: 3 additions & 2 deletions src/core/helpers/html/safe-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
const foreign = box.querySelectorAll('math *, svg *');

for (let i = 0; i < foreign.length; i++) {
if (foreign[i].isConnected && isSmuggledForeignHtml(foreign[i])) {
if (box.contains(foreign[i]) && isSmuggledForeignHtml(foreign[i])) {
Dom.safeRemove(foreign[i]);
}
}
Expand Down Expand Up @@ -219,7 +219,8 @@
// scheme (e.g. `java\tscript:`) — all of which the browser still resolves to
// `javascript:` on click. See GHSA-j839-gqq4-gf9j.
if (safeJavaScriptLink && href && isDangerousUrl(href, tagName)) {
attr(elm, 'href', location.protocol + '//' + href);
const protocol = typeof location !== 'undefined' ? location.protocol : 'http:';

Check failure on line 222 in src/core/helpers/html/safe-html.ts

View workflow job for this annotation

GitHub Actions / build

Replace `·` with `⏎↹↹↹`
attr(elm, 'href', protocol + '//' + href);
effected = true;
}

Expand Down
22 changes: 22 additions & 0 deletions src/plugins/clean-html/clean-html.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,28 @@
});
});

describe('smuggled HTML in MathML/SVG', function () {
it('Should remove HTML smuggled into MathML or SVG when parsed in disconnected fragment', function () {
const editor = getJodit({
cleanHTML: { useIframeSandbox: false }
});
editor.value = '<math><mglyph><html><body onload="alert(1)"></body></html></mglyph></math>';

Check failure on line 840 in src/plugins/clean-html/clean-html.test.js

View workflow job for this annotation

GitHub Actions / build

Replace `·` with `⏎↹↹↹↹↹`
expect(editor.value).does.not.contain('onload');
expect(editor.value).does.not.contain('body');
});
});

describe('smuggled HTML in MathML/SVG', function () {
it('Should remove HTML smuggled into MathML or SVG when parsed in disconnected fragment', function () {
const editor = getJodit({
cleanHTML: { useIframeSandbox: false }
});
editor.value = '<math><mglyph><html><body onload="alert(1)"></body></html></mglyph></math>';

Check failure on line 851 in src/plugins/clean-html/clean-html.test.js

View workflow job for this annotation

GitHub Actions / build

Replace `·` with `⏎↹↹↹↹↹`
expect(editor.value).does.not.contain('onload');
expect(editor.value).does.not.contain('body');
});
});

describe('denyTags (default: script,iframe,object,embed)', function () {
['script', 'iframe', 'object', 'embed'].forEach(function (tag) {
it('Should remove <' + tag + '> by default', function (done) {
Expand Down
2 changes: 1 addition & 1 deletion test/loader.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading