summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/gtk/download_item_gtk.cc6
-rw-r--r--net/base/net_util.cc24
-rw-r--r--net/base/net_util_unittest.cc17
3 files changed, 40 insertions, 7 deletions
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc
index b74951b..f64b30f 100644
--- a/chrome/browser/gtk/download_item_gtk.cc
+++ b/chrome/browser/gtk/download_item_gtk.cc
@@ -548,7 +548,7 @@ void DownloadItemGtk::UpdateStatusLabel(GtkWidget* status_label,
gtk_util::SetLabelColor(status_label, theme_provider_->UseGtkTheme() ?
NULL : &text_color);
- gtk_label_set_label(GTK_LABEL(status_label), status_text.c_str());
+ gtk_label_set_text(GTK_LABEL(status_label), status_text.c_str());
}
void DownloadItemGtk::UpdateDangerWarning() {
@@ -583,8 +583,8 @@ void DownloadItemGtk::UpdateDangerWarning() {
gtk_util::SetLabelColor(dangerous_label_, &color);
}
- gtk_label_set_label(GTK_LABEL(dangerous_label_),
- WideToUTF8(dangerous_warning).c_str());
+ gtk_label_set_text(GTK_LABEL(dangerous_label_),
+ WideToUTF8(dangerous_warning).c_str());
// Until we switch to vector graphics, force the font size.
gtk_util::ForceFontSizePixels(dangerous_label_, kTextSize);
diff --git a/net/base/net_util.cc b/net/base/net_util.cc
index 60f626d4..5eb2e68 100644
--- a/net/base/net_util.cc
+++ b/net/base/net_util.cc
@@ -272,6 +272,11 @@ bool DecodeWord(const std::string& encoded_word,
const std::string& referrer_charset,
bool* is_rfc2047,
std::string* output) {
+ *is_rfc2047 = false;
+ output->clear();
+ if (encoded_word.empty())
+ return true;
+
if (!IsStringASCII(encoded_word)) {
// Try UTF-8, referrer_charset and the native OS default charset in turn.
if (IsStringUTF8(encoded_word)) {
@@ -287,7 +292,7 @@ bool DecodeWord(const std::string& encoded_word,
*output = WideToUTF8(base::SysNativeMBToWide(encoded_word));
}
}
- *is_rfc2047 = false;
+
return true;
}
@@ -1081,7 +1086,7 @@ FilePath GetSuggestedFilename(const GURL& url,
}
const std::string filename_from_cd = GetFileNameFromCD(content_disposition,
- referrer_charset);
+ referrer_charset);
#if defined(OS_WIN)
FilePath::StringType filename = UTF8ToWide(filename_from_cd);
#elif defined(OS_POSIX)
@@ -1102,10 +1107,21 @@ FilePath GetSuggestedFilename(const GURL& url,
const std::string unescaped_url_filename = UnescapeURLComponent(
url.ExtractFileName(),
UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS);
+
+ // The URL's path should be escaped UTF-8, but may not be.
+ std::string decoded_filename = unescaped_url_filename;
+ if (!IsStringASCII(decoded_filename)) {
+ bool ignore;
+ // TODO(jshin): this is probably not robust enough. To be sure, we
+ // need encoding detection.
+ DecodeWord(unescaped_url_filename, referrer_charset, &ignore,
+ &decoded_filename);
+ }
+
#if defined(OS_WIN)
- filename = UTF8ToWide(unescaped_url_filename);
+ filename = UTF8ToWide(decoded_filename);
#elif defined(OS_POSIX)
- filename = unescaped_url_filename;
+ filename = decoded_filename;
#endif
}
}
diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc
index dff3d1c..9bc5d58 100644
--- a/net/base/net_util_unittest.cc
+++ b/net/base/net_util_unittest.cc
@@ -1060,6 +1060,23 @@ TEST(NetUtilTest, GetSuggestedFilename) {
"",
L"",
L"test"},
+ // The filename encoding is specified by the referrer charset.
+ {"http://example.com/V%FDvojov%E1%20psychologie.doc",
+ "",
+ "iso-8859-1",
+ L"",
+ L"V\u00fdvojov\u00e1 psychologie.doc"},
+ // The filename encoding doesn't match the referrer charset, the
+ // system charset, or UTF-8.
+ // TODO(jshin): we need to handle this case.
+#if 0
+ {"http://example.com/V%FDvojov%E1%20psychologie.doc",
+ "",
+ "utf-8",
+ L"",
+ L"V\u00fdvojov\u00e1 psychologie.doc",
+ },
+#endif
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
#if defined(OS_WIN)