File tree Expand file tree Collapse file tree
tests/Unit/Form/Fields/Formatters Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,7 +41,25 @@ private function sanitizer(): HtmlSanitizer
4141 {
4242 $ config = (new HtmlSanitizerConfig ())
4343 ->allowSafeElements ()
44- ->allowElement ('iframe ' )
44+ ->allowElement ('iframe ' , [
45+ 'allow ' ,
46+ 'allowfullscreen ' ,
47+ 'loading ' ,
48+ 'name ' ,
49+ 'referrerpolicy ' ,
50+ 'sandbox ' ,
51+ 'src ' ,
52+ 'srcdoc ' ,
53+ 'width ' ,
54+ 'height ' ,
55+ 'id ' ,
56+ 'title ' ,
57+ 'aria-label ' ,
58+ 'frameborder ' ,
59+ 'marginwidth ' ,
60+ 'marginheight ' ,
61+ 'scrolling ' ,
62+ ])
4563 ->allowRelativeLinks ()
4664 ->allowRelativeMedias ()
4765 ->allowElement ('div ' , ['data-encoded-content ' ])
Original file line number Diff line number Diff line change 355355it ('sanitizes HTML content from front by default ' , function () {
356356 $ value = <<<'HTML'
357357 This is unwanted:
358- 1_<script>alert('XSS')</script>
359- 2_<img src="xss.jpg" onload="alert('XSS')">
358+ <script>alert('XSS')</script>
359+ <img src="javascript:alert('XSS')" onload="alert('XSS')">
360+ <iframe src="javascript:alert('XSS')" onerror="alert('XSS')"></iframe>
360361 This is wanted:
361- 1_<x-embed data-key="0"></x-embed>
362- 2_<x-sharp-file data-key="0"></x-sharp-file>
363- 3_<div data-html-content="true"><script></script></div>
362+ <x-embed data-key="0"></x-embed>
363+ <x-sharp-file data-key="0"></x-sharp-file>
364+ <div data-html-content="true"><script></script></div>
365+ <iframe src="/test" allow="fullscreen" allowfullscreen width="50" height="50" frameborder="0" scrolling="false"></iframe>
364366 HTML;
365367
366368 $ expected = <<<'HTML'
367369 This is unwanted:
368- 1_
369- 2_<img src="xss.jpg">
370+
371+ <img>
372+ <iframe></iframe>
370373 This is wanted:
371- 1_<x-embed></x-embed>
372- 2_<x-sharp-file file="[]"></x-sharp-file>
373- 3_<div data-html-content="true"><script></script></div>
374+ <x-embed></x-embed>
375+ <x-sharp-file file="[]"></x-sharp-file>
376+ <div data-html-content="true"><script></script></div>
377+ <iframe src="/test" allow="fullscreen" allowfullscreen width="50" height="50" frameborder="0" scrolling="false"></iframe>
374378 HTML;
375379
376380 expect (
You can’t perform that action at this time.
0 commit comments