File tree Expand file tree Collapse file tree
src/core/components/providers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,12 +5,10 @@ import { linkify } from "remarkable/linkify"
55import DomPurify from "dompurify"
66import cx from "classnames"
77
8- if ( DomPurify . addHook ) {
9- DomPurify . addHook ( "beforeSanitizeElements" , function ( current , ) {
10- // Attach safe `rel` values to all elements that contain an `href`,
11- // i.e. all anchors that are links.
12- // We _could_ just look for elements that have a non-self target,
13- // but applying it more broadly shouldn't hurt anything, and is safer.
8+ const scopedDomPurify = typeof window !== "undefined" ? DomPurify ( window ) : DomPurify
9+
10+ if ( scopedDomPurify . addHook ) {
11+ scopedDomPurify . addHook ( "beforeSanitizeElements" , function ( current ) {
1412 if ( current . href ) {
1513 current . setAttribute ( "rel" , "noopener noreferrer" )
1614 }
@@ -62,7 +60,7 @@ export function sanitizer(str, { useUnsafeMarkdown = false } = {}) {
6260 sanitizer . hasWarnedAboutDeprecation = true
6361 }
6462
65- return DomPurify . sanitize ( str , {
63+ return scopedDomPurify . sanitize ( str , {
6664 ADD_ATTR : [ "target" ] ,
6765 FORBID_TAGS : [ "style" , "form" ] ,
6866 ALLOW_DATA_ATTR ,
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ const devConfig = configBuilder(
6767 module : {
6868 rules : [
6969 {
70- test : / \. j s x ? $ / ,
70+ test : / \. [ j t ] s x ? $ / ,
7171 include : [
7272 path . join ( projectBasePath , "src" ) ,
7373 path . join ( projectBasePath , "node_modules" , "object-assign-deep" ) ,
You can’t perform that action at this time.
0 commit comments