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

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 2896833002: Added validation of the policy specified in the 'csp' attribute (Closed)
Patch Set: Code Review suggestions Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLIFrameElement.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
6 * (http://www.torchmobile.com/) 6 * (http://www.torchmobile.com/)
7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
10 * Copyright (C) 2011 Google Inc. All rights reserved. 10 * Copyright (C) 2011 Google Inc. All rights reserved.
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 DCHECK(ToLocalFrame(parent_frame)->GetDocument()); 1564 DCHECK(ToLocalFrame(parent_frame)->GetDocument());
1565 return ToLocalFrame(parent_frame) 1565 return ToLocalFrame(parent_frame)
1566 ->GetDocument() 1566 ->GetDocument()
1567 ->InsecureNavigationsToUpgrade(); 1567 ->InsecureNavigationsToUpgrade();
1568 } 1568 }
1569 1569
1570 void FrameLoader::ModifyRequestForCSP(ResourceRequest& resource_request, 1570 void FrameLoader::ModifyRequestForCSP(ResourceRequest& resource_request,
1571 Document* document) const { 1571 Document* document) const {
1572 if (RuntimeEnabledFeatures::embedderCSPEnforcementEnabled() && 1572 if (RuntimeEnabledFeatures::embedderCSPEnforcementEnabled() &&
1573 !RequiredCSP().IsEmpty()) { 1573 !RequiredCSP().IsEmpty()) {
1574 // TODO(amalika): Strengthen this DCHECK that requiredCSP has proper format 1574 DCHECK(ContentSecurityPolicy::IsValidCSPAttr(RequiredCSP().GetString()));
1575 DCHECK(RequiredCSP().GetString().ContainsOnlyASCII());
1576 resource_request.SetHTTPHeaderField(HTTPNames::Required_CSP, RequiredCSP()); 1575 resource_request.SetHTTPHeaderField(HTTPNames::Required_CSP, RequiredCSP());
1577 } 1576 }
1578 1577
1579 // Tack an 'Upgrade-Insecure-Requests' header to outgoing navigational 1578 // Tack an 'Upgrade-Insecure-Requests' header to outgoing navigational
1580 // requests, as described in 1579 // requests, as described in
1581 // https://w3c.github.io/webappsec/specs/upgrade/#feature-detect 1580 // https://w3c.github.io/webappsec/specs/upgrade/#feature-detect
1582 if (resource_request.GetFrameType() != WebURLRequest::kFrameTypeNone) { 1581 if (resource_request.GetFrameType() != WebURLRequest::kFrameTypeNone) {
1583 // Early return if the request has already been upgraded. 1582 // Early return if the request has already been upgraded.
1584 if (!resource_request.HttpHeaderField(HTTPNames::Upgrade_Insecure_Requests) 1583 if (!resource_request.HttpHeaderField(HTTPNames::Upgrade_Insecure_Requests)
1585 .IsNull()) { 1584 .IsNull()) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 // TODO(japhet): This is needed because the browser process DCHECKs if the 1677 // TODO(japhet): This is needed because the browser process DCHECKs if the
1679 // first entry we commit in a new frame has replacement set. It's unclear 1678 // first entry we commit in a new frame has replacement set. It's unclear
1680 // whether the DCHECK is right, investigate removing this special case. 1679 // whether the DCHECK is right, investigate removing this special case.
1681 bool replace_current_item = load_type == kFrameLoadTypeReplaceCurrentItem && 1680 bool replace_current_item = load_type == kFrameLoadTypeReplaceCurrentItem &&
1682 (!Opener() || !request.Url().IsEmpty()); 1681 (!Opener() || !request.Url().IsEmpty());
1683 loader->SetReplacesCurrentHistoryItem(replace_current_item); 1682 loader->SetReplacesCurrentHistoryItem(replace_current_item);
1684 return loader; 1683 return loader;
1685 } 1684 }
1686 1685
1687 } // namespace blink 1686 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLIFrameElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698