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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLLinkElement.cpp

Issue 2418083002: Fix LinkStyle SRI check when against 0 sized resource. (Closed)
Patch Set: review 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/resources/empty.css ('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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
6 * reserved. 6 * reserved.
7 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com) 7 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com)
8 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * Copyright (C) 2011 Google Inc. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 427 }
428 428
429 // See the comment in PendingScript.cpp about why this check is necessary 429 // See the comment in PendingScript.cpp about why this check is necessary
430 // here, instead of in the resource fetcher. https://crbug.com/500701. 430 // here, instead of in the resource fetcher. https://crbug.com/500701.
431 if (!cachedStyleSheet->errorOccurred() && 431 if (!cachedStyleSheet->errorOccurred() &&
432 !m_owner->fastGetAttribute(HTMLNames::integrityAttr).isEmpty() && 432 !m_owner->fastGetAttribute(HTMLNames::integrityAttr).isEmpty() &&
433 !cachedStyleSheet->integrityMetadata().isEmpty()) { 433 !cachedStyleSheet->integrityMetadata().isEmpty()) {
434 ResourceIntegrityDisposition disposition = 434 ResourceIntegrityDisposition disposition =
435 cachedStyleSheet->integrityDisposition(); 435 cachedStyleSheet->integrityDisposition();
436 436
437 DCHECK(disposition != ResourceIntegrityDisposition::NotChecked ||
438 !cachedStyleSheet->sheetText().isNull());
439
440 if (disposition == ResourceIntegrityDisposition::NotChecked && 437 if (disposition == ResourceIntegrityDisposition::NotChecked &&
441 !cachedStyleSheet->loadFailedOrCanceled()) { 438 !cachedStyleSheet->loadFailedOrCanceled()) {
442 DCHECK(cachedStyleSheet->resourceBuffer()); 439 bool checkResult;
443 if (SubresourceIntegrity::CheckSubresourceIntegrity( 440
444 *m_owner, cachedStyleSheet->resourceBuffer()->data(), 441 // cachedStyleSheet->resourceBuffer() can be nullptr on load success.
445 cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href), 442 // If response size == 0.
446 *cachedStyleSheet)) 443 const char* data = nullptr;
447 disposition = ResourceIntegrityDisposition::Passed; 444 size_t size = 0;
448 else 445 if (cachedStyleSheet->resourceBuffer()) {
449 disposition = ResourceIntegrityDisposition::Failed; 446 data = cachedStyleSheet->resourceBuffer()->data();
447 size = cachedStyleSheet->resourceBuffer()->size();
448 }
449 checkResult = SubresourceIntegrity::CheckSubresourceIntegrity(
yhirano 2016/10/17 02:10:32 How about defining |checkResult| here?
450 *m_owner, data, size, KURL(baseURL, href), *cachedStyleSheet);
451 disposition = checkResult ? ResourceIntegrityDisposition::Passed
452 : ResourceIntegrityDisposition::Failed;
450 453
451 // TODO(kouhei): Remove this const_cast crbug.com/653502 454 // TODO(kouhei): Remove this const_cast crbug.com/653502
452 const_cast<CSSStyleSheetResource*>(cachedStyleSheet) 455 const_cast<CSSStyleSheetResource*>(cachedStyleSheet)
453 ->setIntegrityDisposition(disposition); 456 ->setIntegrityDisposition(disposition);
454 } 457 }
455 458
456 if (disposition == ResourceIntegrityDisposition::Failed) { 459 if (disposition == ResourceIntegrityDisposition::Failed) {
457 m_loading = false; 460 m_loading = false;
458 removePendingSheet(); 461 removePendingSheet();
459 notifyLoadedSheetAndAllCriticalSubresources( 462 notifyLoadedSheetAndAllCriticalSubresources(
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 removePendingSheet(); 765 removePendingSheet();
763 } 766 }
764 767
765 DEFINE_TRACE(LinkStyle) { 768 DEFINE_TRACE(LinkStyle) {
766 visitor->trace(m_sheet); 769 visitor->trace(m_sheet);
767 LinkResource::trace(visitor); 770 LinkResource::trace(visitor);
768 ResourceOwner<StyleSheetResource>::trace(visitor); 771 ResourceOwner<StyleSheetResource>::trace(visitor);
769 } 772 }
770 773
771 } // namespace blink 774 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/resources/empty.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698