Skip to content

Commit cdb40e5

Browse files
committed
Remove dedup_source_list and replace with a "best-effort" .uniq call.
1 parent af92ce6 commit cdb40e5

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

lib/secure_headers/headers/content_security_policy.rb

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def minify_source_list(directive, source_list)
133133
unless directive == REPORT_URI || @preserve_schemes
134134
source_list = strip_source_schemes(source_list)
135135
end
136-
dedup_source_list(source_list)
136+
source_list.uniq
137137
end
138138
end
139139

@@ -151,24 +151,6 @@ def reject_all_values_if_none(source_list)
151151
end
152152
end
153153

154-
# Removes duplicates and sources that already match an existing wild card.
155-
#
156-
# e.g. *.github.com asdf.github.com becomes *.github.com
157-
def dedup_source_list(sources)
158-
sources = sources.uniq
159-
wild_sources = sources.select { |source| source =~ STAR_REGEXP }
160-
161-
if wild_sources.any?
162-
schemes = sources.map { |source| [source, URI(source).scheme] }.to_h
163-
sources.reject do |source|
164-
!wild_sources.include?(source) &&
165-
wild_sources.any? { |pattern| schemes[pattern] == schemes[source] && File.fnmatch(pattern, source) }
166-
end
167-
else
168-
sources
169-
end
170-
end
171-
172154
# Private: append a nonce to the script/style directories if script_nonce
173155
# or style_nonce are provided.
174156
def populate_nonces(directive, source_list)

0 commit comments

Comments
 (0)