Skip to content

Commit f46a160

Browse files
committed
add deprecation warning for csp directive values that are procs
1 parent e46b315 commit f46a160

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/secure_headers/headers/content_security_policy.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,13 @@ def initialize(config=nil, options={})
137137

138138
# Config values can be string, array, or lamdba values
139139
@config = config.inject({}) do |hash, (key, value)|
140-
config_val = value.respond_to?(:call) ? value.call(@controller) : value
140+
config_val = if value.respond_to?(:call)
141+
warn "[DEPRECATION] secure_headers 3.x will not support procs as config values."
142+
value.call(@controller)
143+
else
144+
value
145+
end
146+
141147
if ALL_DIRECTIVES.include?(key.to_sym) # directives need to be normalized to arrays of strings
142148
if config_val.is_a? String
143149
warn "[DEPRECATION] A String was supplied for directive #{key}. secure_headers 3.x will require all directives to be arrays of strings."

0 commit comments

Comments
 (0)