Don't sniff file URLs for HTML.
If a file with an extension other than html / htm is downloaded, and
Chrome was used to open the file, it could sniff it as being HTML,
which seems unexpected.
The new logic is not applied to WebView, as existing consumers may
depend on the legacy behavior.
Bug: 777737
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: Iaa72004a3a8de2df99f154c95014e4f6351ce532
Reviewed-on: https://chromium-review.googlesource.com/853036
Commit-Queue: Matt Menke <[email protected]>
Reviewed-by: Jacob Dufault <[email protected]>
Reviewed-by: Richard Coles <[email protected]>
Reviewed-by: Ben Wells <[email protected]>
Reviewed-by: Daichi Hirono <[email protected]>
Reviewed-by: Sylvain Defresne <[email protected]>
Reviewed-by: John Abd-El-Malek <[email protected]>
Reviewed-by: Asanka Herath <[email protected]>
Cr-Commit-Position: refs/heads/master@{#533429}
diff --git a/content/browser/file_url_loader_factory.cc b/content/browser/file_url_loader_factory.cc
index 7632bc5..777fa28 100644
--- a/content/browser/file_url_loader_factory.cc
+++ b/content/browser/file_url_loader_factory.cc
@@ -23,6 +23,7 @@
#include "build/build_config.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/file_url_loader.h"
+#include "content/public/common/content_client.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "mojo/public/cpp/system/file_data_pipe_producer.h"
@@ -522,8 +523,12 @@
}
if (!net::GetMimeTypeFromFile(path, &head.mime_type)) {
- net::SniffMimeType(initial_read_buffer, initial_read_result, request.url,
- head.mime_type, &head.mime_type);
+ net::SniffMimeType(
+ initial_read_buffer, initial_read_result, request.url, head.mime_type,
+ GetContentClient()->browser()->ForceSniffingFileUrlsForHtml()
+ ? net::ForceSniffFileUrlsForHtml::kEnabled
+ : net::ForceSniffFileUrlsForHtml::kDisabled,
+ &head.mime_type);
}
client->OnReceiveResponse(head, base::nullopt, nullptr);
client->OnStartLoadingResponseBody(std::move(pipe.consumer_handle));