Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
salt.23387
fix-file.find-tracebacks-with-non-utf8-file-nam...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File fix-file.find-tracebacks-with-non-utf8-file-names-bs.patch of Package salt.23387
From 7f387d15c8cd7947ea64a94088c2a8bbd52c944e Mon Sep 17 00:00:00 2001 From: Victor Zhestkov <35733135+vzhestkov@users.noreply.github.com> Date: Mon, 8 Nov 2021 17:40:02 +0300 Subject: [PATCH] Fix file.find tracebacks with non utf8 file names (bsc#1190114) (#427) --- salt/modules/file.py | 4 ++++ salt/utils/find.py | 5 ++++- salt/utils/path.py | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/salt/modules/file.py b/salt/modules/file.py index c834adfcde..8a9fd84a99 100644 --- a/salt/modules/file.py +++ b/salt/modules/file.py @@ -1078,6 +1078,10 @@ def find(path, *args, **kwargs): return 'error: {0}'.format(ex) ret = [item for i in [finder.find(p) for p in glob.glob(os.path.expanduser(path))] for item in i] + if six.PY2: + ret = [i.decode('utf-8', 'replace') if isinstance(i, str) else i for i in ret] + else: + ret = [i.encode('utf-8', 'replace').decode('utf-8') for i in ret] ret.sort() return ret diff --git a/salt/utils/find.py b/salt/utils/find.py index b78385dbf8..6ef26ccc74 100644 --- a/salt/utils/find.py +++ b/salt/utils/find.py @@ -648,7 +648,10 @@ class Finder(object): depth = path_depth(relpath) + 1 if depth >= self.mindepth and (self.maxdepth is None or self.maxdepth >= depth): for name in dirs + files: - fullpath = os.path.join(dirpath, name) + try: + fullpath = os.path.join(dirpath, name) + except UnicodeDecodeError: + fullpath = os.path.join(dirpath.encode('utf-8'), name) match, fstat = self._check_criteria(dirpath, name, fullpath) if match: for result in self._perform_actions(fullpath, fstat=fstat): diff --git a/salt/utils/path.py b/salt/utils/path.py index 6cbbf3a08e..0c1a146eea 100644 --- a/salt/utils/path.py +++ b/salt/utils/path.py @@ -453,4 +453,4 @@ def os_walk(top, *args, **kwargs): else: top_query = salt.utils.stringutils.to_str(top) for item in os.walk(top_query, *args, **kwargs): - yield salt.utils.data.decode(item, preserve_tuples=True) + yield salt.utils.data.decode(item, keep=True, preserve_tuples=True) -- 2.33.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor