You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-23 22:36:32 +02:00
Desktop, Mobile: Security: Disable SVG tag support in editor to prevent XSS
This commit is contained in:
@@ -35,7 +35,7 @@ describe('MdToHtml', () => {
|
|||||||
const mdFilePath = `${basePath}/${mdFilename}`;
|
const mdFilePath = `${basePath}/${mdFilename}`;
|
||||||
const htmlPath = `${basePath}/${filename(mdFilePath)}.html`;
|
const htmlPath = `${basePath}/${filename(mdFilePath)}.html`;
|
||||||
|
|
||||||
// if (mdFilename !== 'sanitize_9.md') continue;
|
if (mdFilename !== 'sanitize_15.md') continue;
|
||||||
|
|
||||||
const mdToHtmlOptions: any = {
|
const mdToHtmlOptions: any = {
|
||||||
bodyOnly: true,
|
bodyOnly: true,
|
||||||
|
|||||||
1
packages/app-cli/tests/md_to_html/sanitize_15.html
Normal file
1
packages/app-cli/tests/md_to_html/sanitize_15.html
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<use href="data:image/svg+xml,<svg id='x' xmlns='http://www.w3.org/2000/svg'><image href='asdf' onerror='top.require(`child_process`).execSync(`calc.exe`)' /></svg>#x" class="jop-noMdConv">
|
||||||
1
packages/app-cli/tests/md_to_html/sanitize_15.md
Normal file
1
packages/app-cli/tests/md_to_html/sanitize_15.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg><use href="data:image/svg+xml,<svg id='x' xmlns='http://www.w3.org/2000/svg'><image href='asdf' onerror='top.require(`child_process`).execSync(`calc.exe`)' /></svg>#x" />
|
||||||
|
After Width: | Height: | Size: 193 B |
@@ -183,17 +183,21 @@ class HtmlUtils {
|
|||||||
|
|
||||||
// The BASE tag allows changing the base URL from which files are
|
// The BASE tag allows changing the base URL from which files are
|
||||||
// loaded, and that can break several plugins, such as Katex (which
|
// loaded, and that can break several plugins, such as Katex (which
|
||||||
// needs to load CSS files using a relative URL). For that reason
|
// needs to load CSS files using a relative URL). For that reason it is
|
||||||
// it is disabled. More info:
|
// disabled. More info: https://github.com/laurent22/joplin/issues/3021
|
||||||
// https://github.com/laurent22/joplin/issues/3021
|
|
||||||
//
|
//
|
||||||
// "link" can be used to escape the parser and inject JavaScript.
|
// "link" can be used to escape the parser and inject JavaScript. Adding
|
||||||
// Adding "meta" too for the same reason as it shouldn't be used in
|
// "meta" too for the same reason as it shouldn't be used in notes
|
||||||
// notes anyway.
|
// anyway.
|
||||||
|
//
|
||||||
|
// There are too many issues with SVG tags and to handle them properly
|
||||||
|
// we should parse them separately. Currently we are not so it is better
|
||||||
|
// to disable them. SVG graphics are still supported via the IMG tag.
|
||||||
const disallowedTags = [
|
const disallowedTags = [
|
||||||
'script', 'iframe', 'frameset', 'frame', 'object', 'base',
|
'script', 'iframe', 'frameset', 'frame', 'object', 'base',
|
||||||
'embed', 'link', 'meta', 'noscript', 'button', 'form',
|
'embed', 'link', 'meta', 'noscript', 'button', 'form',
|
||||||
'input', 'select', 'textarea', 'option', 'optgroup',
|
'input', 'select', 'textarea', 'option', 'optgroup',
|
||||||
|
'svg',
|
||||||
];
|
];
|
||||||
|
|
||||||
const parser = new htmlparser2.Parser({
|
const parser = new htmlparser2.Parser({
|
||||||
|
|||||||
Reference in New Issue
Block a user