Merge pull request #48015 from garethgreenaway/47546_more_unicode_nonsense

[2018.3] more unicode nonsense in archive module
This commit is contained in:
Nicole Thomas 2018-06-07 10:44:54 -04:00 committed by GitHub
commit 406efb161e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -186,12 +186,13 @@ def list_(name,
else {'fileobj': cached.stdout, 'mode': 'r|'}
with contextlib.closing(tarfile.open(**open_kwargs)) as tar_archive:
for member in tar_archive.getmembers():
_member = salt.utils.data.decode(member.name)
if member.issym():
links.append(member.name)
links.append(_member)
elif member.isdir():
dirs.append(member.name + '/')
dirs.append(_member + '/')
else:
files.append(member.name)
files.append(_member)
return dirs, files, links
except tarfile.ReadError:

View File

@ -183,6 +183,21 @@ class ArchiveTest(ModuleCase):
self._tear_down()
@skipIf(not salt.utils.path.which('tar'), 'Cannot find tar executable')
def test_tar_list_unicode(self):
'''
Validate using the tar function to extract archives
'''
self._set_up(arch_fmt='tar', unicode_filename=True)
self.run_function('archive.tar', ['-cvf', self.arch], sources=self.src)
# Test list archive
ret = self.run_function('archive.list', name=self.arch)
self.assertTrue(isinstance(ret, list), six.text_type(ret))
self._assert_artifacts_in_ret(ret)
self._tear_down()
@skipIf(not salt.utils.path.which('gzip'), 'Cannot find gzip executable')
def test_gzip(self):
'''