File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -210,6 +210,8 @@ def combine_policies(original, additions)
210210 raise ContentSecurityPolicyConfigError . new ( "Attempted to override an opt-out CSP config." )
211211 end
212212
213+ original = original . dup if original . frozen?
214+
213215 # in case we would be appending to an empty directive, fill it with the default-src value
214216 additions . keys . each do |directive |
215217 unless original [ directive ] || !source_list? ( directive )
Original file line number Diff line number Diff line change @@ -117,6 +117,17 @@ module SecureHeaders
117117 expect ( csp . value ) . to eq ( "default-src https:; script-src https: anothercdn.com" )
118118 end
119119
120+ it "combines directives where the original value is nil and the hash is frozen" do
121+ Configuration . default do |config |
122+ config . csp = {
123+ default_src : %w( 'self' ) ,
124+ report_only : false
125+ } . freeze
126+ end
127+ combined_config = CSP . combine_policies ( Configuration . get . csp , report_uri : %w( https://report-uri.io/asdf ) )
128+ expect ( combined_config [ :report_uri ] ) . to_not be_nil
129+ end
130+
120131 it "overrides the report_only flag" do
121132 Configuration . default do |config |
122133 config . csp = {
You can’t perform that action at this time.
0 commit comments