From 60238fbf13449e31eeea3b6b09ae5fd799083e76 Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Tue, 4 Sep 2018 14:59:46 +0200
Subject: [PATCH] Fallback to Latin-1 if ASCII and UTF-8 doesn't work
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Latin-1 is a standard fallback for HTTP headers, but no one that
HTTPContentDisposition::Parse considers by default.

Task-number: QTBUG-70288
Change-Id: Ife36fffe31da5492cde49a4d447cfc42b3f64b95
Reviewed-by: Zakor Tamas <ztamas@inf.u-szeged.hu>
Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
---
 src/core/download_manager_delegate_qt.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index 4ed77688e..9fe233577 100644
--- a/src/core/download_manager_delegate_qt.cpp
+++ b/src/core/download_manager_delegate_qt.cpp
@@ -43,6 +43,7 @@
 #include "content/public/browser/download_manager.h"
 #include "content/public/browser/save_page_type.h"
 #include "content/public/browser/web_contents.h"
+#include "net/base/net_string_util.h"
 #include "net/http/http_content_disposition.h"
 
 #include <QDir>
@@ -136,7 +137,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(download::DownloadItem*
     }
 
     if (suggestedFilename.isEmpty())
-        suggestedFilename = toQt(net::HttpContentDisposition(item->GetContentDisposition(), std::string()).filename());
+        suggestedFilename = toQt(net::HttpContentDisposition(item->GetContentDisposition(), net::kCharsetLatin1).filename());
 
     if (suggestedFilename.isEmpty())
         suggestedFilename = toQt(item->GetTargetFilePath().AsUTF8Unsafe());
-- 
GitLab