@@ -47,6 +47,7 @@ class ContentSecurityPolicy
47
47
'object-src ' => 'objectSrc ' ,
48
48
'plugin-types ' => 'pluginTypes ' ,
49
49
'script-src ' => 'scriptSrc ' ,
50
+ 'script-src-elem ' => 'scriptSrcElem ' ,
50
51
'style-src ' => 'styleSrc ' ,
51
52
'manifest-src ' => 'manifestSrc ' ,
52
53
'sandbox ' => 'sandbox ' ,
@@ -144,6 +145,13 @@ class ContentSecurityPolicy
144
145
*/
145
146
protected $ scriptSrc = [];
146
147
148
+ /**
149
+ * Used for security enforcement
150
+ *
151
+ * @var array|string
152
+ */
153
+ protected $ scriptSrcElem = [];
154
+
147
155
/**
148
156
* Used for security enforcement
149
157
*
@@ -641,6 +649,23 @@ public function addScriptSrc($uri, ?bool $explicitReporting = null)
641
649
return $ this ;
642
650
}
643
651
652
+ /**
653
+ * Adds a new valid endpoint for javascript file sources. Can be either
654
+ * a URI class or a simple string.
655
+ *
656
+ * @see https://www.w3.org/TR/CSP/#directive-script-src-elem
657
+ *
658
+ * @param array|string $uri
659
+ *
660
+ * @return $this
661
+ */
662
+ public function addScriptSrcElem ($ uri , ?bool $ explicitReporting = null )
663
+ {
664
+ $ this ->addOption ($ uri , 'scriptSrcElem ' , $ explicitReporting ?? $ this ->reportOnly );
665
+
666
+ return $ this ;
667
+ }
668
+
644
669
/**
645
670
* Adds a new valid endpoint for CSS file sources. Can be either
646
671
* a URI class or a simple string.
0 commit comments