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

Side by Side 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 unified diff | Download patch
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 if (!port) 99 if (!port)
100 return isDefaultPortForProtocol(m_port, protocol); 100 return isDefaultPortForProtocol(m_port, protocol);
101 101
102 if (!m_port) 102 if (!m_port)
103 return isDefaultPortForProtocol(port, protocol); 103 return isDefaultPortForProtocol(port, protocol);
104 104
105 return false; 105 return false;
106 } 106 }
107 107
108 bool CSPSource::subsumes(CSPSource* other) {
109 if (!schemeMatches(other->m_scheme))
110 return false;
111
112 if (other->isSchemeOnly() || isSchemeOnly())
113 return isSchemeOnly();
114
115 if ((m_hostWildcard == NoWildcard && other->m_hostWildcard == HasWildcard) ||
116 (m_portWildcard == NoWildcard && other->m_portWildcard == HasWildcard)) {
117 return false;
118 }
119
120 bool hostSubsumes = (m_host == other->m_host || hostMatches(other->m_host));
121 bool portSubsumes = (m_portWildcard == HasWildcard) ||
122 portMatches(other->m_port, other->m_scheme);
123 bool pathSubsumes = pathMatches(other->m_path);
124 return hostSubsumes && portSubsumes && pathSubsumes;
125 }
126
108 bool CSPSource::isSchemeOnly() const { 127 bool CSPSource::isSchemeOnly() const {
109 return m_host.isEmpty(); 128 return m_host.isEmpty();
110 } 129 }
111 130
112 DEFINE_TRACE(CSPSource) { 131 DEFINE_TRACE(CSPSource) {
113 visitor->trace(m_policy); 132 visitor->trace(m_policy);
114 } 133 }
115 134
116 } // namespace blink 135 } // namespace blink
OLDNEW
« 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