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

Unified Diff: third_party/WebKit/Source/core/html/parser/PreloadRequest.h

Issue 2440803002: Filter out data urls in the preload scanner (Closed)
Patch Set: nits and test 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
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/HTMLResourcePreloaderTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/parser/PreloadRequest.h
diff --git a/third_party/WebKit/Source/core/html/parser/PreloadRequest.h b/third_party/WebKit/Source/core/html/parser/PreloadRequest.h
index 3b5722e5c01b10eb24cfb89c77f39959128f56a8..17680d46733c474608a53bd5eb443ce10e9ed8b5 100644
--- a/third_party/WebKit/Source/core/html/parser/PreloadRequest.h
+++ b/third_party/WebKit/Source/core/html/parser/PreloadRequest.h
@@ -30,7 +30,9 @@ class PreloadRequest {
RequestTypeLinkRelPreload
};
- static std::unique_ptr<PreloadRequest> create(
+ // TODO(csharrison): Move the implementation to the cpp file when core/html
+ // gets its own testing source set in html/BUILD.gn.
+ static std::unique_ptr<PreloadRequest> createIfNeeded(
const String& initiatorName,
const TextPosition& initiatorPosition,
const String& resourceURL,
@@ -42,6 +44,14 @@ class PreloadRequest {
const ClientHintsPreferences& clientHintsPreferences =
ClientHintsPreferences(),
RequestType requestType = RequestTypePreload) {
+ // Never preload data URLs. We also disallow relative ref URLs which become
+ // data URLs if the document's URL is a data URL. We don't want to create
+ // extra resource requests with data URLs to avoid copy / initialization
+ // overhead, which can be significant for large URLs.
+ if (resourceURL.isEmpty() || resourceURL.startsWith("#") ||
+ protocolIs(resourceURL, "data")) {
+ return nullptr;
+ }
return wrapUnique(new PreloadRequest(
initiatorName, initiatorPosition, resourceURL, baseURL, resourceType,
resourceWidth, clientHintsPreferences, requestType, referrerPolicy));
« no previous file with comments | « third_party/WebKit/Source/core/html/parser/HTMLResourcePreloaderTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698