| Index: net/base/filename_util_internal.cc
|
| diff --git a/net/base/filename_util_internal.cc b/net/base/filename_util_internal.cc
|
| index 49b6a3db923d52fef031f1a666563422241dc793..cda7f62c01c8896d01d007585b02b0a8e3f97d36 100644
|
| --- a/net/base/filename_util_internal.cc
|
| +++ b/net/base/filename_util_internal.cc
|
| @@ -229,11 +229,13 @@ base::string16 GetSuggestedFilenameImpl(
|
| FILE_PATH_LITERAL("download");
|
| std::string filename; // In UTF-8
|
| bool overwrite_extension = false;
|
| -
|
| + bool is_name_from_content_disposition = false;
|
| // Try to extract a filename from content-disposition first.
|
| if (!content_disposition.empty()) {
|
| HttpContentDisposition header(content_disposition, referrer_charset);
|
| filename = header.filename();
|
| + if (!filename.empty())
|
| + is_name_from_content_disposition = true;
|
| }
|
|
|
| // Then try to use the suggested name.
|
| @@ -275,7 +277,13 @@ base::string16 GetSuggestedFilenameImpl(
|
| }
|
| replace_illegal_characters_callback.Run(&result_str, '-');
|
| base::FilePath result(result_str);
|
| - GenerateSafeFileName(mime_type, overwrite_extension, &result);
|
| + // extension should not appended to filename derived from
|
| + // content-disposition, if it does not have one.
|
| + // Hence mimetype and overwrite_extension values are not used.
|
| + if (is_name_from_content_disposition)
|
| + GenerateSafeFileName("", false, &result);
|
| + else
|
| + GenerateSafeFileName(mime_type, overwrite_extension, &result);
|
|
|
| base::string16 result16;
|
| if (!FilePathToString16(result, &result16)) {
|
|
|