File tree Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " domiso " : patch
3
+ ---
4
+
5
+ chore: add xml test case, update description
Original file line number Diff line number Diff line change 13
13
[ ![ Code Style: Prettier] ( https://img.shields.io/badge/code_style-prettier-ff69b4.svg )] ( https://github.com/prettier/prettier )
14
14
[ ![ changesets] ( https://img.shields.io/badge/maintained%20with-changesets-176de3.svg )] ( https://github.com/atlassian/changesets )
15
15
16
- Dom sanitizer based on browser native DOMParser
16
+ The smallest and fastest Dom sanitizer based on browser native DOMParser
17
17
18
18
## TOC <!-- omit in toc -->
19
19
Original file line number Diff line number Diff line change 2
2
"name" : " domiso" ,
3
3
"version" : " 0.0.0" ,
4
4
"type" : " module" ,
5
- "description" : " Dom sanitizer based on browser native DOMParser" ,
5
+ "description" : " The smallest and fastest Dom sanitizer based on browser native DOMParser" ,
6
6
"repository" : " git+https://github.com/un-ts/domiso.git" ,
7
7
"author" : " JounQin (https://www.1stG.me) <admin@1stg.me>" ,
8
8
"donate" : {
Original file line number Diff line number Diff line change @@ -14,4 +14,36 @@ test('Remove listeners and scripts', () => {
14
14
15
15
</svg>"
16
16
` )
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
+ ` )
17
49
} )
You can’t perform that action at this time.
0 commit comments