mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Accounting for when files in an archive contain non-ascii characters
This commit is contained in:
parent
cb04d9c37e
commit
5a9cadd125
2 changed files with 19 additions and 8 deletions
|
@ -413,12 +413,20 @@ def list_(name,
|
|||
ret = {'dirs': sorted(dirs),
|
||||
'files': sorted(files),
|
||||
'links': sorted(links)}
|
||||
ret['top_level_dirs'] = [x for x in ret['dirs']
|
||||
if x.count('/') == 1]
|
||||
ret['top_level_files'] = [x for x in ret['files']
|
||||
if x.count('/') == 0]
|
||||
ret['top_level_links'] = [x for x in ret['links']
|
||||
if x.count('/') == 0]
|
||||
if six.PY2:
|
||||
ret['top_level_dirs'] = [x for x in ret['dirs']
|
||||
if x.decode('utf-8').count('/') == 1]
|
||||
ret['top_level_files'] = [x for x in ret['files']
|
||||
if x.decode('utf-8').count('/') == 0]
|
||||
ret['top_level_links'] = [x for x in ret['links']
|
||||
if x.decode('utf-8').count('/') == 0]
|
||||
else:
|
||||
ret['top_level_dirs'] = [x for x in ret['dirs']
|
||||
if x.count('/') == 1]
|
||||
ret['top_level_files'] = [x for x in ret['files']
|
||||
if x.count('/') == 0]
|
||||
ret['top_level_links'] = [x for x in ret['links']
|
||||
if x.count('/') == 0]
|
||||
else:
|
||||
ret = sorted(dirs + files + links)
|
||||
return ret
|
||||
|
|
|
@ -1090,7 +1090,10 @@ def extracted(name,
|
|||
and not stat.S_ISDIR(x)),
|
||||
(contents['links'], stat.S_ISLNK)):
|
||||
for path in path_list:
|
||||
full_path = os.path.join(name, path)
|
||||
if six.PY2:
|
||||
full_path = os.path.join(name, path.decode('utf-8'))
|
||||
else:
|
||||
full_path = os.path.join(name, path)
|
||||
try:
|
||||
path_mode = os.lstat(full_path.rstrip(os.sep)).st_mode
|
||||
if not func(path_mode):
|
||||
|
@ -1259,7 +1262,7 @@ def extracted(name,
|
|||
if options is None:
|
||||
try:
|
||||
with closing(tarfile.open(cached, 'r')) as tar:
|
||||
tar.extractall(name)
|
||||
tar.extractall(salt.utils.to_bytes(name))
|
||||
files = tar.getnames()
|
||||
if trim_output:
|
||||
files = files[:trim_output]
|
||||
|
|
Loading…
Add table
Reference in a new issue