Skip to content

Commit

Permalink
Fix dropping of WebP images to the Finder.
Browse files Browse the repository at this point in the history
mime_util does not take extensions with a leading dot, and if you
pass in an extension with a leading dot, you will not successfully
look up a mime type.

BUG=84003
TEST=as in bug

Change-Id: I37d9b0946df61a557b3423ae8a13ae447ed6c7c1
Reviewed-on: https://chromium-review.googlesource.com/c/1493473
Auto-Submit: Avi Drissman <avi@chromium.org>
Reviewed-by: Leonard Grey <lgrey@chromium.org>
Reviewed-by: Matt Menke <mmenke@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636446}
  • Loading branch information
Avi Drissman authored and Commit Bot committed Feb 28, 2019
1 parent 849ceff commit 5432215
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion content/browser/web_contents/web_drag_source_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ - (void)fillPasteboard {
dropData_->GetSafeFilenameForImageFileContents();
if (suggestedFilename) {
downloadFileName_ = std::move(*suggestedFilename);
net::GetMimeTypeFromExtension(downloadFileName_.Extension(), &mimeType);
net::GetMimeTypeFromFile(downloadFileName_, &mimeType);
}
} else {
base::string16 mimeType16;
Expand Down
3 changes: 3 additions & 0 deletions net/base/mime_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ bool MimeUtil::GetMimeTypeFromExtensionHelper(
const base::FilePath::StringType& ext,
bool include_platform_types,
string* result) const {
DCHECK(ext.empty() || ext[0] != '.')
<< "extension passed in must not include leading dot";

// Avoids crash when unable to handle a long file path. See crbug.com/48733.
const unsigned kMaxFilePathSize = 65536;
if (ext.length() > kMaxFilePathSize)
Expand Down

0 comments on commit 5432215

Please sign in to comment.