File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -213,11 +213,11 @@ def combine_policies(original, additions)
213213 # when each hash contains a value for a given key.
214214 original . merge ( additions ) do |directive , lhs , rhs |
215215 if source_list? ( directive )
216- lhs | rhs
216+ ( lhs . to_a + rhs ) . uniq . compact
217217 else
218218 rhs
219219 end
220- end
220+ end . reject { | _ , value | value . nil? || value == [ ] } # this mess prevents us from adding empty directives.
221221 end
222222
223223 private
Original file line number Diff line number Diff line change @@ -117,6 +117,9 @@ module SecureHeaders
117117
118118 specify { expect ( ContentSecurityPolicy . idempotent_additions? ( { script_src : %w( a.com b.com ) } , script_src : %w( b.com ) ) ) . to be true }
119119 specify { expect ( ContentSecurityPolicy . idempotent_additions? ( { script_src : %w( a.com b.com ) } , script_src : %w( b.com a.com ) ) ) . to be true }
120+ specify { expect ( ContentSecurityPolicy . idempotent_additions? ( { script_src : %w( a.com b.com ) } , script_src : %w( ) ) ) . to be true }
121+ specify { expect ( ContentSecurityPolicy . idempotent_additions? ( { script_src : %w( a.com b.com ) } , script_src : [ nil ] ) ) . to be true }
122+ specify { expect ( ContentSecurityPolicy . idempotent_additions? ( { script_src : %w( a.com b.com ) } , style_src : [ nil ] ) ) . to be true }
120123 end
121124
122125 describe "#value" do
You can’t perform that action at this time.
0 commit comments