summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-01-20 11:01:10 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-01-20 12:04:51 +0100
commitf5d89fc9ba86ae95a7e9fcbbf7ecb0ea5b03255e (patch)
treeafb62c9752aa4957fe05015a5272f72208d6e950
parent6fd2077b6c84e0e3c9beb40f34ede9b3dc9a7c4f (diff)
downloadqutebrowser-f5d89fc9ba86ae95a7e9fcbbf7ecb0ea5b03255e.tar.gz
qutebrowser-f5d89fc9ba86ae95a7e9fcbbf7ecb0ea5b03255e.zip
Handle null bytes in filepath completion
-rw-r--r--qutebrowser/completion/models/filepathcategory.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/qutebrowser/completion/models/filepathcategory.py b/qutebrowser/completion/models/filepathcategory.py
index 5d6367a13..30f79e024 100644
--- a/qutebrowser/completion/models/filepathcategory.py
+++ b/qutebrowser/completion/models/filepathcategory.py
@@ -27,6 +27,7 @@ from typing import List, Optional, Iterable
from PyQt5.QtCore import QAbstractListModel, QModelIndex, QObject, Qt, QUrl
from qutebrowser.config import config
+from qutebrowser.utils import log
class FilePathCategory(QAbstractListModel):
@@ -54,7 +55,12 @@ class FilePathCategory(QAbstractListModel):
"""Find paths based on the given pattern."""
if not os.path.isabs(val):
return []
- return glob.glob(glob.escape(val) + '*')
+ try:
+ return glob.glob(glob.escape(val) + '*')
+ except ValueError as e: # pragma: no cover
+ # e.g. "embedded null byte" with \x00 on Python 3.6 and 3.7
+ log.completion.debug(f"Failed to glob: {e}")
+ return []
def _url_to_path(self, val: str) -> str:
"""Get a path from a file:/// URL."""