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

Unified Diff: Source/core/html/HTMLLinkElement.cpp

Issue 622783004: Implementation of subresource integrity attribute for style sheets. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on ToT Created 6 years, 2 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 | « LayoutTests/http/tests/security/subresourceIntegrity/subresource-integrity-style-blocked-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLLinkElement.cpp
diff --git a/Source/core/html/HTMLLinkElement.cpp b/Source/core/html/HTMLLinkElement.cpp
index 725217d564185e6dce1e2d0ebecd2a23a2d44b73..93bc16b9007e9dd898acf7c74176ffd66054762e 100644
--- a/Source/core/html/HTMLLinkElement.cpp
+++ b/Source/core/html/HTMLLinkElement.cpp
@@ -42,6 +42,7 @@
#include "core/fetch/ResourceFetcher.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
+#include "core/frame/SubresourceIntegrity.h"
#include "core/frame/csp/ContentSecurityPolicy.h"
#include "core/html/LinkManifest.h"
#include "core/html/imports/LinkImport.h"
@@ -501,8 +502,14 @@ void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const
if (!m_owner->inDocument()) {
ASSERT(!m_sheet);
return;
+ }
+ if (!SubresourceIntegrity::CheckSubresourceIntegrity(*m_owner, cachedStyleSheet->sheetText(), KURL(KURL(), href))) {
+ m_loading = false;
+ removePendingSheet();
+ return;
}
+
// Completing the sheet load may cause scripts to execute.
RefPtrWillBeRawPtr<Node> protector(m_owner.get());
@@ -527,6 +534,7 @@ void LinkStyle::setCSSStyleSheet(const String& href, const KURL& baseURL, const
if (m_sheet)
clearSheet();
+
m_sheet = CSSStyleSheet::create(styleSheet, m_owner);
m_sheet->setMediaQueries(MediaQuerySet::create(m_owner->media()));
m_sheet->setTitle(m_owner->title());
« no previous file with comments | « LayoutTests/http/tests/security/subresourceIntegrity/subresource-integrity-style-blocked-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698