From bc4430e5d9863cc30c3b807d37ec7a32c64f4d10 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Fri, 24 Mar 2017 11:36:19 +0100 Subject: [PATCH] prevent reserved filenames on Windows Fixes #82 Prevents filenames like COM1, ... --- qutebrowser/mainwindow/prompt.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py index b8b842057..ff676146d 100644 --- a/qutebrowser/mainwindow/prompt.py +++ b/qutebrowser/mainwindow/prompt.py @@ -23,6 +23,7 @@ import re import sys import os.path import html +import pathlib import collections import sip @@ -657,6 +658,10 @@ class FilenamePrompt(_BasePrompt): # E:filename is invalid if re.match(r'[A-Z]:[^\\]', path, re.IGNORECASE): return None + # Paths like COM1, ... + # See https://github.com/qutebrowser/qutebrowser/issues/82 + if pathlib.Path(path).is_reserved(): + return None return path def _show_error(self, msg):