File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,14 @@ def normalize_uri_paths(source_list)
152152 source_list . map do |source |
153153 # Normalize domains ending in a single / as without omitting the slash accomplisheg the same.
154154 # https://www.w3.org/TR/CSP3/#match-paths § 6.6.2.10 Step 2
155+ begin
156+ uri = URI ( source )
157+ if uri . path == "/"
158+ next source . chomp ( "/" )
159+ end
160+ rescue URI ::InvalidURIError
161+ end
162+
155163 if source . chomp ( "/" ) . include? ( "/" )
156164 source
157165 else
Original file line number Diff line number Diff line change @@ -50,10 +50,10 @@ module SecureHeaders
5050
5151 it "normalizes source expressions that end with a trailing /" do
5252 config = {
53- default_src : %w( a.example.org/ b.example.com/ c.example.net/foo/ b.example.co/bar )
53+ default_src : %w( a.example.org/ b.example.com/ wss:// c.example.com/ c.example. net/foo/ b.example.co/bar wss://b.example.co/ )
5454 }
5555 csp = ContentSecurityPolicy . new ( config )
56- expect ( csp . value ) . to eq ( "default-src a.example.org b.example.com c.example.net/foo/ b.example.co/bar" )
56+ expect ( csp . value ) . to eq ( "default-src a.example.org b.example.com wss:// c.example.com c.example. net/foo/ b.example.co/bar wss://b.example.co " )
5757 end
5858
5959 it "minifies source expressions based on overlapping wildcards" do
You can’t perform that action at this time.
0 commit comments