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

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

Issue 1362813002: CSP source *.x.y should not match host x.y (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Test fixes Created 5 years, 3 months 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
« no previous file with comments | « Source/core/frame/UseCounter.h ('k') | Source/core/frame/csp/CSPSourceListTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/csp/CSPSource.cpp
diff --git a/Source/core/frame/csp/CSPSource.cpp b/Source/core/frame/csp/CSPSource.cpp
index 461f566fc55746d1002d568cc0e85c6d26c70cf2..5be05dad47dd1f5708ded735ec26620edb5355a0 100644
--- a/Source/core/frame/csp/CSPSource.cpp
+++ b/Source/core/frame/csp/CSPSource.cpp
@@ -5,6 +5,7 @@
#include "config.h"
#include "core/frame/csp/CSPSource.h"
+#include "core/frame/UseCounter.h"
#include "core/frame/csp/ContentSecurityPolicy.h"
#include "platform/weborigin/KURL.h"
#include "platform/weborigin/KnownPorts.h"
@@ -44,10 +45,24 @@ bool CSPSource::schemeMatches(const KURL& url) const
bool CSPSource::hostMatches(const KURL& url) const
{
const String& host = url.host();
- if (equalIgnoringCase(host, m_host))
- return true;
- return m_hostWildcard == HasWildcard && host.endsWith("." + m_host, TextCaseInsensitive);
-
+ Document* document = m_policy->document();
+ bool match;
+
+ bool equalHosts = equalIgnoringCase(host, m_host);
+ if (m_hostWildcard == HasWildcard) {
+ match = host.endsWith("." + m_host, TextCaseInsensitive);
+
+ // Chrome used to, incorrectly, match *.x.y to x.y. This was fixed, but
+ // the following count measures when a match fails that would have
+ // passed the old, incorrect style, in case a lot of sites were
+ // relying on that behavior.
+ if (document && equalHosts)
+ UseCounter::count(*document, UseCounter::CSPSourceWildcardWouldMatchExactHost);
+ } else {
+ match = equalHosts;
+ }
+
+ return match;
}
bool CSPSource::pathMatches(const KURL& url) const
« no previous file with comments | « Source/core/frame/UseCounter.h ('k') | Source/core/frame/csp/CSPSourceListTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698