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

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

Issue 2209113002: Change wildcard source expression matching to conform latest spec (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust CSP of feedback extension Created 4 years, 4 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
Index: third_party/WebKit/Source/core/frame/csp/CSPSourceList.cpp
diff --git a/third_party/WebKit/Source/core/frame/csp/CSPSourceList.cpp b/third_party/WebKit/Source/core/frame/csp/CSPSourceList.cpp
index 5a6abf711a295c8198b0af162c3fb18a2c7ad095..4a321b368ed6df02aef3a21fb681a7f24f50be02 100644
--- a/third_party/WebKit/Source/core/frame/csp/CSPSourceList.cpp
+++ b/third_party/WebKit/Source/core/frame/csp/CSPSourceList.cpp
@@ -47,15 +47,16 @@ CSPSourceList::CSPSourceList(ContentSecurityPolicy* policy, const String& direct
bool CSPSourceList::matches(const KURL& url, ResourceRequest::RedirectStatus redirectStatus) const
{
- // The CSP spec specifically states that data:, blob:, and filesystem URLs
- // should not be captured by a '*" source
- // (http://www.w3.org/TR/CSP2/#source-list-guid-matching). Thus, in the
- // case of a full wildcard, data:, blob:, and filesystem: URLs are
+ // The CSP spec specifically states that only http:, https:, ws: and wss: should
+ // be captured by a '*" source.
+ // (https://w3c.github.io/webappsec-csp/#match-url-to-source-expression). Thus,
+ // in the case of a full wildcard, URLs with any other schemes are
// explicitly checked for in the source list before allowing them through.
if (m_allowStar) {
- if (url.protocolIs("blob") || url.protocolIs("data") || url.protocolIs("filesystem"))
- return hasSourceMatchInList(url, redirectStatus);
- return true;
+ if (url.protocolIsInHTTPFamily() || url.protocolIs("ws") || url.protocolIs("wss"))
+ return true;
+
+ return hasSourceMatchInList(url, redirectStatus);
}
KURL effectiveURL = m_policy->selfMatchesInnerURL() && SecurityOrigin::shouldUseInnerURL(url) ? SecurityOrigin::extractInnerURL(url) : url;
« no previous file with comments | « chrome/browser/ui/webui/signin/inline_login_ui.cc ('k') | third_party/WebKit/Source/core/frame/csp/CSPSourceListTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698