summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-07-13 10:23:13 +0200
committerFlorian Bruhin <me@the-compiler.org>2021-07-28 12:46:24 +0200
commitd95b0435d872b92359d9c4c95a1a590b56bee54e (patch)
tree471c8f52ce99555cb69aa19fbf124a822d8a5e60
parent28a80dac0125cab5fc7dc7374d2c39e7bd8b93bd (diff)
downloadqutebrowser-d95b0435d872b92359d9c4c95a1a590b56bee54e.tar.gz
qutebrowser-d95b0435d872b92359d9c4c95a1a590b56bee54e.zip
Handle UnicodeEncodeError in path completion
(cherry picked from commit 0001d4fe20a4cdef9dd628fad220e09a03618932)
-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 ac5dd2278..f9b6608a3 100644
--- a/qutebrowser/completion/models/filepathcategory.py
+++ b/qutebrowser/completion/models/filepathcategory.py
@@ -91,7 +91,13 @@ class FilePathCategory(QAbstractListModel):
for path in self._glob(url_path)
)
else:
- paths = self._glob(os.path.expanduser(val))
+ try:
+ expanded = os.path.expanduser(val)
+ except UnicodeEncodeError:
+ # os.path.expanduser('~\ud800') can raise UnicodeEncodeError
+ # via pwd.getpwnam
+ expanded = val
+ paths = self._glob(expanded)
self._paths = sorted(self._contract_user(val, path) for path in paths)
def data(self, index: QModelIndex, role: int = Qt.DisplayRole) -> Optional[str]: