Index: Source/core/html/parser/HTMLPreloadScanner.cpp |
diff --git a/Source/core/html/parser/HTMLPreloadScanner.cpp b/Source/core/html/parser/HTMLPreloadScanner.cpp |
index 6c988f0ff0d89fe86e5414b7b8fd28b61455bdbc..084de2ba37ccbdb11cbd84deb5ebf128ccc79851 100644 |
--- a/Source/core/html/parser/HTMLPreloadScanner.cpp |
+++ b/Source/core/html/parser/HTMLPreloadScanner.cpp |
@@ -374,6 +374,7 @@ TokenPreloadScanner::TokenPreloadScanner(const KURL& documentURL, PassRefPtr<Med |
, m_inStyle(false) |
, m_inPicture(false) |
, m_isAppCacheEnabled(false) |
+ , m_isCSPEnabled(false) |
, m_templateCount(0) |
, m_mediaValues(mediaValues) |
{ |
@@ -386,7 +387,7 @@ TokenPreloadScanner::~TokenPreloadScanner() |
TokenPreloadScannerCheckpoint TokenPreloadScanner::createCheckpoint() |
{ |
TokenPreloadScannerCheckpoint checkpoint = m_checkpoints.size(); |
- m_checkpoints.append(Checkpoint(m_predictedBaseElementURL, m_inStyle, m_isAppCacheEnabled, m_templateCount)); |
+ m_checkpoints.append(Checkpoint(m_predictedBaseElementURL, m_inStyle, m_isAppCacheEnabled, m_isCSPEnabled, m_templateCount)); |
return checkpoint; |
} |
@@ -397,6 +398,7 @@ void TokenPreloadScanner::rewindTo(TokenPreloadScannerCheckpoint checkpointIndex |
m_predictedBaseElementURL = checkpoint.predictedBaseElementURL; |
m_inStyle = checkpoint.inStyle; |
m_isAppCacheEnabled = checkpoint.isAppCacheEnabled; |
+ m_isCSPEnabled = checkpoint.isCSPEnabled; |
m_templateCount = checkpoint.templateCount; |
m_cssScanner.reset(); |
m_checkpoints.clear(); |
@@ -419,6 +421,10 @@ void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString& |
if (m_isAppCacheEnabled) |
return; |
+ // http://crbug.com/434230 Disable preload for documents with CSP <meta> tags |
+ if (m_isCSPEnabled) |
+ return; |
+ |
switch (token.type()) { |
case HTMLToken::Character: { |
if (!m_inStyle) |
@@ -466,6 +472,13 @@ void TokenPreloadScanner::scanCommon(const Token& token, const SegmentedString& |
m_isAppCacheEnabled = true; |
return; |
} |
+ if (match(tagImpl, metaTag)) { |
+ const typename Token::Attribute* equivAttribute = token.getAttributeItem(http_equivAttr); |
+ if (equivAttribute && equalIgnoringCase(String(equivAttribute->value), "content-security-policy")) { |
+ m_isCSPEnabled = true; |
+ return; |
+ } |
+ } |
if (RuntimeEnabledFeatures::pictureEnabled() && (match(tagImpl, pictureTag))) { |
m_inPicture = true; |