diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 4a79c8543..6b52eba9b 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -51,6 +51,7 @@ Fixed - Fixed crashes when opening an empty URL (e.g. via pasting). - Fixed validation of duplicate values in `hints -> chars`. - Fixed crash when PDF.js was partially installed. +- Fixed crash when XDG_DOWNLOAD_DIR was not an absolute path. v0.5.1 ------ diff --git a/qutebrowser/browser/downloads.py b/qutebrowser/browser/downloads.py index 667e8e7a2..c3c6203d9 100644 --- a/qutebrowser/browser/downloads.py +++ b/qutebrowser/browser/downloads.py @@ -534,6 +534,22 @@ class DownloadItem(QObject): self._filename = create_full_filename( self.basename, os.path.join(download_dir(), filename)) + # At this point, we have a misconfigured XDG_DOWNLOAd_DIR, as + # download_dir() + filename is still no absolute path. + # The config value is checked for "absoluteness", but + # ~/.config/user-dirs.dirs may be misconfigured and a non-absolute path + # may be set for XDG_DOWNLOAD_DIR + if self._filename is None: + message.error( + self._win_id, + "XDG_DOWNLOAD_DIR points to a relative path - please check" + " your ~/.config/user-dirs.dirs. The download is saved in" + " your home directory.", + ) + # fall back to $HOME as download_dir + self._filename = create_full_filename( + self.basename, os.path.expanduser(os.path.join('~', filename))) + self.basename = os.path.basename(self._filename) last_used_directory = os.path.dirname(self._filename)