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

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: Getting rid of similarity 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..43722fd1a3a30920c13e071cef09bed41c5e5464 100644
--- a/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/CSPSource.cpp
@@ -105,6 +105,26 @@ bool CSPSource::portMatches(int port, const String& protocol) const {
return false;
}
+bool CSPSource::isSubsumingOf(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 hostIsSubsumingOf =
+ (m_host == other->m_host || hostMatches(other->m_host));
+ bool portIsSubsumingOf = (m_portWildcard == HasWildcard) ||
+ portMatches(other->m_port, other->m_scheme);
+ bool pathIsSubsumingOf = pathMatches(other->m_path);
+ return hostIsSubsumingOf && portIsSubsumingOf && pathIsSubsumingOf;
+}
+
bool CSPSource::isSchemeOnly() const {
return m_host.isEmpty();
}

Powered by Google App Engine
This is Rietveld 408576698