Skip to content
Open
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
1 change: 1 addition & 0 deletions src/transform/sanitize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ export const defaultOptions: SanitizeOptions = {
'xlink:href',
'from',
'to',
'values',
],
allowVulnerableTags: true,
parser: defaultParseOptions,
Expand Down
68 changes: 68 additions & 0 deletions test/__snapshots__/xss.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,40 @@ exports[`XSS checks with disabled markdown-it-attrs You can EMBED SVG which can
</p>
`;

exports[`XSS checks with disabled markdown-it-attrs animate with values attribute 1`] = `
<p>
<svg>
<animate xlink:href="#xss"
attributename="href"
>
</animate>
<a id="xss">
<text x="20"
y="20"
>
XSS
</text>
</a>
</svg>
</p>
`;

exports[`XSS checks with disabled markdown-it-attrs animate with values attribute and data: scheme 1`] = `
<p>
<svg>
<animate xlink:href="#x"
attributename="href"
>
</animate>
<a id="x">
<text>
Click
</text>
</a>
</svg>
</p>
`;

exports[`XSS checks with disabled markdown-it-attrs body image 1`] = `""`;

exports[`XSS checks with disabled markdown-it-attrs body tag 1`] = `""`;
Expand Down Expand Up @@ -585,6 +619,40 @@ exports[`XSS checks with enabled markdown-it-attrs You can EMBED SVG which can c
</p>
`;

exports[`XSS checks with enabled markdown-it-attrs animate with values attribute 1`] = `
<p>
<svg>
<animate xlink:href="#xss"
attributename="href"
>
</animate>
<a id="xss">
<text x="20"
y="20"
>
XSS
</text>
</a>
</svg>
</p>
`;

exports[`XSS checks with enabled markdown-it-attrs animate with values attribute and data: scheme 1`] = `
<p>
<svg>
<animate xlink:href="#x"
attributename="href"
>
</animate>
<a id="x">
<text>
Click
</text>
</a>
</svg>
</p>
`;

exports[`XSS checks with enabled markdown-it-attrs body image 1`] = `""`;

exports[`XSS checks with enabled markdown-it-attrs body tag 1`] = `""`;
Expand Down
8 changes: 8 additions & 0 deletions test/xss.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ const ckecks = [
'href animate from',
`<div id="test"><svg><a xmlns:xlink="http://www.w3.org/1999/xlink" href="javascript:alert(document.domain)"><circle r="400"></circle><animate attributeName="href" begin="0" from="javascript:alert(document.domain)" to="&" /></a></div>`,
],
[
'animate with values attribute',
`<svg><animate xlink:href="#xss" attributeName="href" values="javascript:alert(1)"></animate><a id="xss"><text x="20" y="20">XSS</text></a></svg>`,
],
[
'animate with values attribute and data: scheme',
`<svg><animate xlink:href="#x" attributeName="href" values="data:text/html,<script>alert(1)</script>"></animate><a id="x"><text>Click</text></a></svg>`,
],
];

describe.each([
Expand Down