Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Unified Diff: content/browser/android/download_controller_android_impl.cc

Issue 1717783002: Fix an issue that download filename from content disposition is not sanitized (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/download/ChromeDownloadDelegateTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/android/download_controller_android_impl.cc
diff --git a/content/browser/android/download_controller_android_impl.cc b/content/browser/android/download_controller_android_impl.cc
index 76d7f85d3882b020b7f4aa0eeecd352cacdff78a..187cf3a288d5b184851ab3ae302acbedeaed8a13 100644
--- a/content/browser/android/download_controller_android_impl.cc
+++ b/content/browser/android/download_controller_android_impl.cc
@@ -32,6 +32,7 @@
#include "content/public/common/content_client.h"
#include "content/public/common/referrer.h"
#include "jni/DownloadController_jni.h"
+#include "net/base/filename_util.h"
#include "net/cookies/cookie_options.h"
#include "net/cookies/cookie_store.h"
#include "net/http/http_content_disposition.h"
@@ -392,7 +393,14 @@ void DownloadControllerAndroidImpl::StartAndroidDownloadInternal(
// explicitly specified filename if available.
net::HttpContentDisposition header(info.content_disposition, "");
asanka 2016/02/22 22:56:08 header is unused.
qinmin 2016/02/22 23:03:36 Done.
ScopedJavaLocalRef<jstring> jfilename =
- ConvertUTF8ToJavaString(env, header.filename());
+ base::android::ConvertUTF16ToJavaString(
+ env,
+ net::GetSuggestedFilename(info.url,
+ info.content_disposition,
+ std::string(), // referrer_charset
+ std::string(), // suggested_name
+ info.original_mime_type,
+ std::string())); // default name
asanka 2016/02/22 22:56:08 Provide a default name in case one cannot be gener
qinmin 2016/02/22 23:03:36 net::GetSuggestedFilename() will fallback to "down
asanka 2016/02/23 00:05:56 That's not a localized string. See IDS_DEFAULT_DOW
qinmin 2016/02/23 07:23:10 Done. IDS_DEFAULT_DOWNLOAD_FILENAME is defined in
Java_DownloadController_newHttpGetDownload(
env, GetJavaObject()->Controller(env).obj(), view.obj(), jurl.obj(),
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/download/ChromeDownloadDelegateTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698