From 5f4efced7b17d6538b02caf4e1f22d51e90b6f1d Mon Sep 17 00:00:00 2001 From: Jimmy Date: Sun, 27 May 2018 18:03:43 +1200 Subject: [PATCH] Sanitize generated filenames for downloads. Replace characters that Windows doesn't like from generated and suggested filenames for downloads. Does not apply to filenames that a user inters via the downloads location prompt. Fixes #3922 --- qutebrowser/browser/downloads.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index dd112e00a..421b8c08b 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -134,6 +134,7 @@ def create_full_filename(basename, filename): Return: The full absolute path, or None if filename creation was not possible. """ + basename = utils.sanitize_filename(basename) # Remove chars which can't be encoded in the filename encoding. # See https://github.com/qutebrowser/qutebrowser/issues/427 encoding = sys.getfilesystemencoding() @@ -159,6 +160,7 @@ def get_filename_question(*, suggested_filename, url, parent=None): url: The URL the download originated from. parent: The parent of the question (a QObject). """ + suggested_filename = utils.sanitize_filename(suggested_filename) encoding = sys.getfilesystemencoding() suggested_filename = utils.force_encoding(suggested_filename, encoding)