Don't crash when trying to save to a FIFO or other special file

When giving the path to a FIFO or other special file qutebrowser would
completely hang, and has to be killed.

Tested:

- Asks for overwrite: file, symlink to file
- Saves in dir: dir, symlink to dir
- Aborts: block dev, char dev, fifo, socket, and a symlink to all of these
This commit is contained in:
Martin Tournoij 2015-06-08 22:40:55 +02:00
parent 839d2b1cbe
commit 9df5a89037

View File

@ -446,6 +446,13 @@ class DownloadItem(QObject):
# The file already exists, so ask the user if it should be
# overwritten.
self._ask_overwrite_question()
# FIFO, device node, etc. Don't even try.
elif (os.path.exists(self._filename) and not
os.path.isdir(self._filename)):
self.cancel(False)
message.error(self._win_id, "The file {} already exists, and is a "
"special file. Aborting.".format(
self._filename))
else:
self._create_fileobj()