Commit 6dc1a994 authored by Matt Menke's avatar Matt Menke Committed by Commit Bot

File URLs: Only apply MIME sniffing after resolving symbolic links.

Bug: 1035887
Change-Id: If99ff578ad31f6dbd180041fe8b1b0623ef26569
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2033571Reviewed-by: default avatarAsanka Herath <asanka@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737941}
parent d38665c9
......@@ -523,9 +523,11 @@ class FileURLLoader : public network::mojom::URLLoader {
return;
}
// Full file path with all symbolic links resolved.
base::FilePath full_path = base::MakeAbsoluteFilePath(path);
if (file_access_policy == FileAccessPolicy::kRestricted &&
!GetContentClient()->browser()->IsFileAccessAllowed(
path, base::MakeAbsoluteFilePath(path), profile_path)) {
!GetContentClient()->browser()->IsFileAccessAllowed(path, full_path,
profile_path)) {
OnClientComplete(net::ERR_ACCESS_DENIED, std::move(observer));
return;
}
......@@ -669,9 +671,9 @@ class FileURLLoader : public network::mojom::URLLoader {
// TODO(crbug.com/995177): Update mime_util.cc when WebBundles feature is
// launched and stop using GetWebBundleFileMimeTypeFromFile().
if (!web_bundle_utils::GetWebBundleFileMimeTypeFromFile(path,
if (!web_bundle_utils::GetWebBundleFileMimeTypeFromFile(full_path,
&head->mime_type) &&
!net::GetMimeTypeFromFile(path, &head->mime_type)) {
!net::GetMimeTypeFromFile(full_path, &head->mime_type)) {
std::string new_type;
net::SniffMimeType(
initial_read_buffer.data(), read_result.bytes_read, request.url,
......
......@@ -178,9 +178,9 @@ IN_PROC_BROWSER_TEST_F(FileURLLoaderFactoryBrowserTest, SymlinksToFiles) {
// Get an absolute path since |temp_dir| can contain a symbolic link.
base::FilePath absolute_temp_dir = AbsoluteFilePath(temp_dir.GetPath());
// MIME sniffing uses the symbolic link's path, so this needs to end in
// ".html" for it to be sniffed as HTML.
base::FilePath sym_link = absolute_temp_dir.AppendASCII("link.html");
// MIME sniffing should use the symbolic link's destination path, so despite
// not having a file extension of "html", this should be rendered as HTML.
base::FilePath sym_link = absolute_temp_dir.AppendASCII("link.bin");
ASSERT_TRUE(
base::CreateSymbolicLink(AbsoluteFilePath(TestFilePath()), sym_link));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment