File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3434 return window . DOMPurify . sanitize ( html , { RETURN_TRUSTED_TYPE : false } ) ;
3535 }
3636
37- // Very conservative fallback: strip <script> tags and common inline event handlers.
38- const parser = new DOMParser ( ) ;
39- const doc = parser . parseFromString ( html , "text/html" ) ;
40-
41- // Remove all <script> elements.
42- doc . querySelectorAll ( "script" ) . forEach ( ( el ) => el . remove ( ) ) ;
43-
44- // Remove inline event handlers such as onclick, onload, etc.
45- doc . querySelectorAll ( "*" ) . forEach ( ( el ) => {
46- [ ...el . attributes ] . forEach ( ( attr ) => {
47- if ( / ^ o n / i. test ( attr . name ) ) {
48- el . removeAttribute ( attr . name ) ;
49- }
50- } ) ;
51- } ) ;
52-
53- return doc . documentElement . innerHTML ;
37+ // If DOMPurify is not available, do not attempt to sanitize manually.
38+ // Returning an empty string avoids rendering untrusted HTML with a weak sanitizer.
39+ return "" ;
5440 }
5541
5642 // Notify host that we are ready to receive the app resource
You can’t perform that action at this time.
0 commit comments