Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(513)

Side by Side Diff: third_party/WebKit/Source/core/frame/csp/CSPSource.cpp

Issue 2550093005: Embedding-CSP: Fixing path matching (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/frame/csp/CSPSource.h" 5 #include "core/frame/csp/CSPSource.h"
6 6
7 #include "core/frame/UseCounter.h" 7 #include "core/frame/UseCounter.h"
8 #include "core/frame/csp/ContentSecurityPolicy.h" 8 #include "core/frame/csp/ContentSecurityPolicy.h"
9 #include "platform/weborigin/KURL.h" 9 #include "platform/weborigin/KURL.h"
10 #include "platform/weborigin/KnownPorts.h" 10 #include "platform/weborigin/KnownPorts.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 UseCounter::count(*document, 67 UseCounter::count(*document,
68 UseCounter::CSPSourceWildcardWouldMatchExactHost); 68 UseCounter::CSPSourceWildcardWouldMatchExactHost);
69 } else { 69 } else {
70 match = equalHosts; 70 match = equalHosts;
71 } 71 }
72 72
73 return match; 73 return match;
74 } 74 }
75 75
76 bool CSPSource::pathMatches(const String& urlPath) const { 76 bool CSPSource::pathMatches(const String& urlPath) const {
77 if (m_path.isEmpty()) 77 if (m_path.isEmpty() || (m_path == "/" && urlPath.isEmpty()))
Mike West 2016/12/08 08:25:52 Can you add a test to `CSPSourceTest.cpp`?
78 return true; 78 return true;
79 79
80 String path = decodeURLEscapeSequences(urlPath); 80 String path = decodeURLEscapeSequences(urlPath);
81 81
82 if (m_path.endsWith("/")) 82 if (m_path.endsWith("/"))
83 return path.startsWith(m_path); 83 return path.startsWith(m_path);
84 84
85 return path == m_path; 85 return path == m_path;
86 } 86 }
87 87
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return false; 189 return false;
190 } 190 }
191 return true; 191 return true;
192 } 192 }
193 193
194 DEFINE_TRACE(CSPSource) { 194 DEFINE_TRACE(CSPSource) {
195 visitor->trace(m_policy); 195 visitor->trace(m_policy);
196 } 196 }
197 197
198 } // namespace blink 198 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/csp/SourceListDirectiveTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698