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

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

Issue 2442513004: Part 1.1: Is policy list subsumed under subsuming policy? (Closed)
Patch Set: Changing comment Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/frame/csp/CSPSource.cpp
diff --git a/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp b/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp
index 7b6be14df07012db9a466cba5bf8d1f89d9e452f..212b8ce74d3d96aa6f0850ae4276c97e303844a6 100644
--- a/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp
@@ -105,6 +105,25 @@ bool CSPSource::portMatches(int port, const String& protocol) const {
return false;
}
+bool CSPSource::subsumes(CSPSource* other) {
+ if (!schemeMatches(other->m_scheme))
+ return false;
+
+ if (other->isSchemeOnly() || isSchemeOnly())
+ return isSchemeOnly();
+
+ if ((m_hostWildcard == NoWildcard && other->m_hostWildcard == HasWildcard) ||
+ (m_portWildcard == NoWildcard && other->m_portWildcard == HasWildcard)) {
+ return false;
+ }
+
+ bool hostSubsumes = (m_host == other->m_host || hostMatches(other->m_host));
+ bool portSubsumes = (m_portWildcard == HasWildcard) ||
+ portMatches(other->m_port, other->m_scheme);
+ bool pathSubsumes = pathMatches(other->m_path);
+ return hostSubsumes && portSubsumes && pathSubsumes;
+}
+
bool CSPSource::isSchemeOnly() const {
return m_host.isEmpty();
}
« no previous file with comments | « third_party/WebKit/Source/core/frame/csp/CSPSource.h ('k') | third_party/WebKit/Source/core/frame/csp/CSPSourceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698