Skip to content

Commit 0e277f0

Browse files
authored
chore: add xml test case, update description (#2)
1 parent 1352829 commit 0e277f0

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

.changeset/thirty-candles-give.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"domiso": patch
3+
---
4+
5+
chore: add xml test case, update description

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
[![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
1414
[![changesets](https://img.shields.io/badge/maintained%20with-changesets-176de3.svg)](https://github.com/atlassian/changesets)
1515

16-
Dom sanitizer based on browser native DOMParser
16+
The smallest and fastest Dom sanitizer based on browser native DOMParser
1717

1818
## TOC <!-- omit in toc -->
1919

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "domiso",
33
"version": "0.0.0",
44
"type": "module",
5-
"description": "Dom sanitizer based on browser native DOMParser",
5+
"description": "The smallest and fastest Dom sanitizer based on browser native DOMParser",
66
"repository": "git+https://github.com/un-ts/domiso.git",
77
"author": "JounQin (https://www.1stG.me) <admin@1stg.me>",
88
"donate": {

test/svg.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,36 @@ test('Remove listeners and scripts', () => {
1414
1515
</svg>"
1616
`)
17+
18+
expect(
19+
sanitizeSvg(/* HTML */ `<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
20+
<svg
21+
t="1658933732986"
22+
class="icon"
23+
viewBox="0 0 1024 1024"
24+
version="1.1"
25+
xmlns="http://www.w3.org/2000/svg"
26+
p-id="15882"
27+
xmlns:xlink="http://www.w3.org/1999/xlink"
28+
width="200"
29+
height="200"
30+
onclick="alert('XSS!')"
31+
>
32+
<defs><style type="text/css"></style></defs>
33+
<path
34+
d="M650.11172 266.667111l262.059595 148.009348c25.824844 14.448261 44.254909 43.287899 44.254909 75.768044v295.961813c0 28.896521-18.430065 57.73616-44.254909 75.768045l-262.116477 147.952465c-11.092169 7.281013-29.579116 10.864637-44.311792 10.864637-14.789558 0-29.522233-3.640507-44.254909-10.807755l-262.116478-148.009347a87.599691 87.599691 0 0 1-44.254908-75.768045V490.444503c0-32.423262 14.789558-61.319784 44.254908-75.768044L561.488137 266.667111a96.132128 96.132128 0 0 1 88.623583 0z m115.07414 518.942844l-318.828745 2.104668 131.854599 93.174217 186.974146-95.278885z m-187.599858-288.225736l-143.1743 270.648915 139.476911-24.573419 3.697389-246.075496z m37.82714-101.82042l-1.36519 345.108653 214.903657 25.312897-213.538467-370.364667z"
35+
p-id="15883"
36+
></path>
37+
<path
38+
d="M500.452768 153.868288l31.854433 55.176429L220.19064 390.728751a54.209419 54.209419 0 0 0-24.687186 27.190034c-4.209336 10.750871-5.688292 20.47785-4.550633 29.351585h0.39818v382.480728a102.389249 102.389249 0 0 0 4.6644 24.516537c4.09557 11.831647 13.253719 22.525635 27.417565 32.138848L369.79271 971.901506c10.011393 15.642802 11.262817 28.839639 3.868038 39.533627-7.451662 10.693988-21.444859 14.505144-41.979592 11.376583l-162.514492-93.287983c-11.3197-8.248023-21.160445-21.103562-29.579116-38.452851-8.418672-17.292407-12.343593-37.713373-11.831647-61.319784h-0.170649V447.952965h-0.170648a142.889885 142.889885 0 0 1 9.670095-55.290195c6.541535-16.211631 17.235524-32.081965 32.081965-47.554118l331.286104-191.297247zM602.671368 0l136.689648 104.664566-101.763537 0.227531v3.469858c-1.023892 13.822549-9.670096 28.782756-25.824844 44.937504-18.486948 18.543831-45.05127 36.86013-79.692966 55.00578L500.623417 153.982054c29.465351-13.595017 49.772552-26.905619 60.978486-39.98869a54.835131 54.835131 0 0 0 6.200238-8.873735l-103.470025 0.170649L602.671368 0z"
39+
p-id="15884"
40+
></path>
41+
</svg>`),
42+
).toMatchInlineSnapshot(`
43+
"<svg t=\\"1658933732986\\" class=\\"icon\\" viewBox=\\"0 0 1024 1024\\" version=\\"1.1\\" xmlns=\\"http://www.w3.org/2000/svg\\" p-id=\\"15882\\" xmlns:xlink=\\"http://www.w3.org/1999/xlink\\" width=\\"200\\" height=\\"200\\">
44+
<defs><style type=\\"text/css\\"/></defs>
45+
<path d=\\"M650.11172 266.667111l262.059595 148.009348c25.824844 14.448261 44.254909 43.287899 44.254909 75.768044v295.961813c0 28.896521-18.430065 57.73616-44.254909 75.768045l-262.116477 147.952465c-11.092169 7.281013-29.579116 10.864637-44.311792 10.864637-14.789558 0-29.522233-3.640507-44.254909-10.807755l-262.116478-148.009347a87.599691 87.599691 0 0 1-44.254908-75.768045V490.444503c0-32.423262 14.789558-61.319784 44.254908-75.768044L561.488137 266.667111a96.132128 96.132128 0 0 1 88.623583 0z m115.07414 518.942844l-318.828745 2.104668 131.854599 93.174217 186.974146-95.278885z m-187.599858-288.225736l-143.1743 270.648915 139.476911-24.573419 3.697389-246.075496z m37.82714-101.82042l-1.36519 345.108653 214.903657 25.312897-213.538467-370.364667z\\" p-id=\\"15883\\"/>
46+
<path d=\\"M500.452768 153.868288l31.854433 55.176429L220.19064 390.728751a54.209419 54.209419 0 0 0-24.687186 27.190034c-4.209336 10.750871-5.688292 20.47785-4.550633 29.351585h0.39818v382.480728a102.389249 102.389249 0 0 0 4.6644 24.516537c4.09557 11.831647 13.253719 22.525635 27.417565 32.138848L369.79271 971.901506c10.011393 15.642802 11.262817 28.839639 3.868038 39.533627-7.451662 10.693988-21.444859 14.505144-41.979592 11.376583l-162.514492-93.287983c-11.3197-8.248023-21.160445-21.103562-29.579116-38.452851-8.418672-17.292407-12.343593-37.713373-11.831647-61.319784h-0.170649V447.952965h-0.170648a142.889885 142.889885 0 0 1 9.670095-55.290195c6.541535-16.211631 17.235524-32.081965 32.081965-47.554118l331.286104-191.297247zM602.671368 0l136.689648 104.664566-101.763537 0.227531v3.469858c-1.023892 13.822549-9.670096 28.782756-25.824844 44.937504-18.486948 18.543831-45.05127 36.86013-79.692966 55.00578L500.623417 153.982054c29.465351-13.595017 49.772552-26.905619 60.978486-39.98869a54.835131 54.835131 0 0 0 6.200238-8.873735l-103.470025 0.170649L602.671368 0z\\" p-id=\\"15884\\"/>
47+
</svg>"
48+
`)
1749
})

0 commit comments

Comments
 (0)