Also call sanitize_filename in TempDownloadManager

Just in case the suggested name used for the temp file suffix somehow
has an illegal character in it.
This commit is contained in:
Jimmy 2018-06-26 15:39:16 +12:00
parent ffd6ffef45
commit 1febcb9fce

View File

@ -1224,8 +1224,7 @@ class TempDownloadManager:
A tempfile.NamedTemporaryFile that should be used to save the file. A tempfile.NamedTemporaryFile that should be used to save the file.
""" """
tmpdir = self._get_tmpdir() tmpdir = self._get_tmpdir()
encoding = sys.getfilesystemencoding() suggested_name = utils.sanitize_filename(suggested_name)
suggested_name = utils.force_encoding(suggested_name, encoding)
# Make sure that the filename is not too long # Make sure that the filename is not too long
suggested_name = utils.elide_filename(suggested_name, 50) suggested_name = utils.elide_filename(suggested_name, 50)
fobj = tempfile.NamedTemporaryFile(dir=tmpdir.name, delete=False, fobj = tempfile.NamedTemporaryFile(dir=tmpdir.name, delete=False,