From b17d74452ffffacfb0f545301c771f36be98ee5f Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 7 Oct 2015 12:12:02 +0200 Subject: [PATCH] Expand $HOME before checking if file exists Otherwise we might accidentally overwrite a file. --- qutebrowser/browser/mhtml.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qutebrowser/browser/mhtml.py b/qutebrowser/browser/mhtml.py index da598543d..56fc600e6 100644 --- a/qutebrowser/browser/mhtml.py +++ b/qutebrowser/browser/mhtml.py @@ -435,7 +435,11 @@ def start_download_checked(dest): Args: dest: The filename where the resulting file should be saved. """ - if not os.path.isfile(dest): + # start_download will call os.path.expanduser on dest too, so no need to + # overwrite dest. We just want to make sure that we're checking + # the right path here. This also means that the user question will show the + # original path, not the expanded. + if not os.path.isfile(os.path.expanduser(dest)): start_download(dest) return