Commit 3ce847c9 authored by Dominique Fauteux-Chapleau's avatar Dominique Fauteux-Chapleau Committed by Commit Bot

Check only final extension in DeepScanningDialogDelegate

The previous implementation would result in the entire extension being
used, so atypical ones like "foo.csv.gz" would check if ".csv.gz" had
a corresponding mimetype instead of just checking ".gz".

Bug: 1069347
Change-Id: Ieefb8f4726d4a268e3bc312592a1c53060007210
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2158973Reviewed-by: default avatarRoger Tawa <rogerta@chromium.org>
Commit-Queue: Dominique Fauteux-Chapleau <domfc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#761045}
parent 6d7b7463
...@@ -137,8 +137,15 @@ bool ShouldShowWarning(const DlpDeepScanningVerdict& verdict) { ...@@ -137,8 +137,15 @@ bool ShouldShowWarning(const DlpDeepScanningVerdict& verdict) {
std::string GetFileMimeType(base::FilePath path) { std::string GetFileMimeType(base::FilePath path) {
// TODO(crbug.com/1013252): Obtain a more accurate MimeType by parsing the // TODO(crbug.com/1013252): Obtain a more accurate MimeType by parsing the
// file content. // file content.
base::FilePath::StringType ext = path.FinalExtension();
if (ext.empty())
return "";
if (ext[0] == FILE_PATH_LITERAL('.'))
ext = ext.substr(1);
std::string mime_type; std::string mime_type;
net::GetMimeTypeFromFile(path, &mime_type); net::GetMimeTypeFromExtension(ext, &mime_type);
return mime_type; return mime_type;
} }
......
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