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

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

Issue 2418083002: Fix LinkStyle SRI check when against 0 sized resource. (Closed)
Patch Set: Created 4 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
Index: third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp b/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
index a27a6472c4f8e94e1e0fe0c212804be928e867b0..47953c95c3ce4f91c8f7a463af8a5b5c0714060e 100644
--- a/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLLinkElement.cpp
@@ -434,19 +434,21 @@ void LinkStyle::setCSSStyleSheet(
ResourceIntegrityDisposition disposition =
cachedStyleSheet->integrityDisposition();
- DCHECK(disposition != ResourceIntegrityDisposition::NotChecked ||
- !cachedStyleSheet->sheetText().isNull());
-
if (disposition == ResourceIntegrityDisposition::NotChecked &&
!cachedStyleSheet->loadFailedOrCanceled()) {
- DCHECK(cachedStyleSheet->resourceBuffer());
- if (SubresourceIntegrity::CheckSubresourceIntegrity(
- *m_owner, cachedStyleSheet->resourceBuffer()->data(),
- cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href),
- *cachedStyleSheet))
- disposition = ResourceIntegrityDisposition::Passed;
- else
- disposition = ResourceIntegrityDisposition::Failed;
+ bool checkResult;
+ if (cachedStyleSheet->resourceBuffer()) {
jww 2016/10/14 17:42:11 nit: This could be simplified by having a const ch
kouhei (in TOK) 2016/10/17 01:23:38 Done.
+ checkResult = SubresourceIntegrity::CheckSubresourceIntegrity(
+ *m_owner, cachedStyleSheet->resourceBuffer()->data(),
+ cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href),
+ *cachedStyleSheet);
+ } else {
+ // If resourceBuffer is nullptr, the resource content-size was 0.
+ checkResult = SubresourceIntegrity::CheckSubresourceIntegrity(
+ *m_owner, nullptr, 0, KURL(baseURL, href), *cachedStyleSheet);
+ }
+ disposition = checkResult ? ResourceIntegrityDisposition::Passed
+ : ResourceIntegrityDisposition::Failed;
// TODO(kouhei): Remove this const_cast crbug.com/653502
const_cast<CSSStyleSheetResource*>(cachedStyleSheet)

Powered by Google App Engine
This is Rietveld 408576698