bool CSPSource::matches(const KURL& url, ContentSecurityPolicy::RedirectStatus redirectStatus) const { if (!schemeMatches(url)) return false; if (isSchemeOnly()) return true; bool pathsMatch = (redirectStatus == ContentSecurityPolicy::DidRedirect) || pathMatches(url); return hostMatches(url) && portMatches(url) && pathsMatch; }
bool CSPSource::matches(const KURL& url, ResourceRequest::RedirectStatus redirectStatus) const { bool schemesMatch = m_scheme.isEmpty() ? m_policy->protocolMatchesSelf(url) : schemeMatches(url.protocol()); if (!schemesMatch) return false; if (isSchemeOnly()) return true; bool pathsMatch = (redirectStatus == RedirectStatus::FollowedRedirect) || pathMatches(url.path()); return hostMatches(url.host()) && portMatches(url.port(), url.protocol()) && pathsMatch; }
bool CSPSource::isSimilar(CSPSource* other) const { bool schemesMatch = schemeMatches(other->m_scheme) || other->schemeMatches(m_scheme); if (!schemesMatch || isSchemeOnly() || other->isSchemeOnly()) return schemesMatch; bool hostsMatch = (m_host == other->m_host) || hostMatches(other->m_host) || other->hostMatches(m_host); bool portsMatch = (other->m_portWildcard == HasWildcard) || portMatches(other->m_port, other->m_scheme) || other->portMatches(m_port, m_scheme); bool pathsMatch = pathMatches(other->m_path) || other->pathMatches(m_path); if (hostsMatch && portsMatch && pathsMatch) return true; return false; }
bool CSPSource::subsumes(CSPSource* other) const { 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; }