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

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

Issue 2479703003: Stop preloading scripts that have invalid type/language attributes (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/
4 * Copyright (C) 2010 Google Inc. All Rights Reserved. 4 * Copyright (C) 2010 Google Inc. All Rights Reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 referrerPolicy, resourceWidth, clientHintsPreferences, requestType); 246 referrerPolicy, resourceWidth, clientHintsPreferences, requestType);
247 if (!request) 247 if (!request)
248 return nullptr; 248 return nullptr;
249 249
250 request->setCrossOrigin(m_crossOrigin); 250 request->setCrossOrigin(m_crossOrigin);
251 request->setNonce(m_nonce); 251 request->setNonce(m_nonce);
252 request->setCharset(charset()); 252 request->setCharset(charset());
253 request->setDefer(m_defer); 253 request->setDefer(m_defer);
254 request->setIntegrityMetadata(m_integrityMetadata); 254 request->setIntegrityMetadata(m_integrityMetadata);
255 255
256 // TODO(csharrison): Once this is deprecated, just abort the request here.
257 if (match(m_tagImpl, scriptTag) &&
258 !ScriptLoader::isValidScriptTypeAndLanguage(
259 m_typeAttributeValue, m_languageAttributeValue,
260 ScriptLoader::AllowLegacyTypeInTypeAttribute))
261 request->setScriptHasInvalidTypeOrLanguage();
262 return request; 256 return request;
263 } 257 }
264 258
265 private: 259 private:
266 template <typename NameType> 260 template <typename NameType>
267 void processScriptAttribute(const NameType& attributeName, 261 void processScriptAttribute(const NameType& attributeName,
268 const String& attributeValue) { 262 const String& attributeValue) {
269 // FIXME - Don't set crossorigin multiple times. 263 // FIXME - Don't set crossorigin multiple times.
270 if (match(attributeName, srcAttr)) 264 if (match(attributeName, srcAttr))
271 setUrlToLoad(attributeValue, DisallowURLReplacement); 265 setUrlToLoad(attributeValue, DisallowURLReplacement);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 bool shouldPreload() const { 471 bool shouldPreload() const {
478 if (m_urlToLoad.isEmpty()) 472 if (m_urlToLoad.isEmpty())
479 return false; 473 return false;
480 if (!m_matched) 474 if (!m_matched)
481 return false; 475 return false;
482 if (match(m_tagImpl, linkTag) && !m_linkIsStyleSheet && !m_linkIsImport && 476 if (match(m_tagImpl, linkTag) && !m_linkIsStyleSheet && !m_linkIsImport &&
483 !m_linkIsPreload) 477 !m_linkIsPreload)
484 return false; 478 return false;
485 if (match(m_tagImpl, inputTag) && !m_inputIsImage) 479 if (match(m_tagImpl, inputTag) && !m_inputIsImage)
486 return false; 480 return false;
481 if (match(m_tagImpl, scriptTag) &&
482 !ScriptLoader::isValidScriptTypeAndLanguage(
483 m_typeAttributeValue, m_languageAttributeValue,
484 ScriptLoader::AllowLegacyTypeInTypeAttribute)) {
485 return false;
486 }
487 return true; 487 return true;
488 } 488 }
489 489
490 void setCrossOrigin(const String& corsSetting) { 490 void setCrossOrigin(const String& corsSetting) {
491 m_crossOrigin = crossOriginAttributeValue(corsSetting); 491 m_crossOrigin = crossOriginAttributeValue(corsSetting);
492 } 492 }
493 493
494 void setNonce(const String& nonce) { m_nonce = nonce; } 494 void setNonce(const String& nonce) { m_nonce = nonce; }
495 495
496 void setDefer(FetchRequest::DeferOption defer) { m_defer = defer; } 496 void setDefer(FetchRequest::DeferOption defer) { m_defer = defer; }
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 defaultViewportMinWidth = document->viewportDefaultMinWidth(); 895 defaultViewportMinWidth = document->viewportDefaultMinWidth();
896 viewportMetaZeroValuesQuirk = 896 viewportMetaZeroValuesQuirk =
897 document->settings() && 897 document->settings() &&
898 document->settings()->viewportMetaZeroValuesQuirk(); 898 document->settings()->viewportMetaZeroValuesQuirk();
899 viewportMetaEnabled = 899 viewportMetaEnabled =
900 document->settings() && document->settings()->viewportMetaEnabled(); 900 document->settings() && document->settings()->viewportMetaEnabled();
901 referrerPolicy = document->getReferrerPolicy(); 901 referrerPolicy = document->getReferrerPolicy();
902 } 902 }
903 903
904 } // namespace blink 904 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698