File tree Expand file tree Collapse file tree
packages/forms/resources/views/components
tests/src/Forms/Components Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99<x-dynamic-component :component =" $getFieldWrapperView()" :field =" $field" >
1010 @if ($isDisabled )
1111 <div
12- x-data =" {
13- state: $wire.{{ $applyStateBindingModifiers (" \$ entangle('{$statePath }')" ) } } ,
14- }"
15- x-html =" state"
1612 class =" fi-fo-rich-editor fi-disabled prose block w-full max-w-none rounded-lg bg-gray-50 px-3 py-3 text-gray-500 shadow-sm ring-1 ring-gray-950/10 dark:prose-invert dark:bg-transparent dark:text-gray-400 dark:ring-white/10 sm:text-sm"
17- ></div >
13+ >
14+ {!! str ($getState ())-> sanitizeHtml () ! !}
15+ </div >
1816 @else
1917 <x-filament::input .wrapper
2018 :valid =" ! $errors->has($statePath)"
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Filament \Forms \Components \RichEditor ;
4+ use Filament \Forms \Form ;
5+ use Filament \Tests \Forms \Fixtures \Livewire ;
6+ use Filament \Tests \TestCase ;
7+ use Illuminate \Contracts \View \View ;
8+
9+ use function Filament \Tests \livewire ;
10+
11+ uses (TestCase::class);
12+
13+ it ('sanitizes stored HTML when rendering the disabled state to prevent stored XSS ' , function () {
14+ livewire (TestComponentWithDisabledRichEditor::class)
15+ ->fillForm ([
16+ 'content ' => '<p>Safe paragraph</p><img src=x onerror="window.__xss = true"> ' ,
17+ ])
18+ ->assertDontSeeHtml ('onerror="window.__xss = true" ' );
19+ });
20+
21+ class TestComponentWithDisabledRichEditor extends Livewire
22+ {
23+ public function form (Form $ form ): Form
24+ {
25+ return $ form
26+ ->schema ([
27+ RichEditor::make ('content ' )
28+ ->disabled (),
29+ ])
30+ ->statePath ('data ' );
31+ }
32+
33+ public function render (): View
34+ {
35+ return view ('forms.fixtures.form ' );
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments