diff options
author | Matt Martz <matt@sivel.net> | 2020-04-28 22:33:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-28 22:33:44 +0200 |
commit | bc41dd45141f627b31fbb04443fbaa1ea0c7d1d4 (patch) | |
tree | ff3bbffa283bc9f8fe91c17bb0107dea821c1bcc | |
parent | Be strict about what is a boolean for keywords (#67625) (diff) | |
download | ansible-bc41dd45141f627b31fbb04443fbaa1ea0c7d1d4.tar.xz ansible-bc41dd45141f627b31fbb04443fbaa1ea0c7d1d4.zip |
Handle non-ascii paths during role installation. Fixes #69133 (#69213)
-rw-r--r-- | changelogs/fragments/69133-role-install-non-ascii.yml | 3 | ||||
-rw-r--r-- | lib/ansible/galaxy/role.py | 16 | ||||
-rwxr-xr-x | test/integration/targets/ansible-galaxy/runme.sh | 14 |
3 files changed, 26 insertions, 7 deletions
diff --git a/changelogs/fragments/69133-role-install-non-ascii.yml b/changelogs/fragments/69133-role-install-non-ascii.yml new file mode 100644 index 0000000000..af8cc62031 --- /dev/null +++ b/changelogs/fragments/69133-role-install-non-ascii.yml @@ -0,0 +1,3 @@ +bugfixes: +- Role Installation - Ensure that a role containing files with non-ascii characters can be installed + (https://github.com/ansible/ansible/issues/69133) diff --git a/lib/ansible/galaxy/role.py b/lib/ansible/galaxy/role.py index 75144d852b..7de44dedf8 100644 --- a/lib/ansible/galaxy/role.py +++ b/lib/ansible/galaxy/role.py @@ -329,13 +329,15 @@ class GalaxyRole(object): # bits that might be in the file for security purposes # and drop any containing directory, as mentioned above if member.isreg() or member.issym(): - parts = member.name.replace(archive_parent_dir, "", 1).split(os.sep) - final_parts = [] - for part in parts: - if part != '..' and '~' not in part and '$' not in part: - final_parts.append(part) - member.name = os.path.join(*final_parts) - role_tar_file.extract(member, self.path) + n_member_name = to_native(member.name) + n_archive_parent_dir = to_native(archive_parent_dir) + n_parts = n_member_name.replace(n_archive_parent_dir, "", 1).split(os.sep) + n_final_parts = [] + for n_part in n_parts: + if n_part != '..' and '~' not in n_part and '$' not in n_part: + n_final_parts.append(n_part) + member.name = os.path.join(*n_final_parts) + role_tar_file.extract(member, to_native(self.path)) # write out the install info file for later use self._write_galaxy_install_info() diff --git a/test/integration/targets/ansible-galaxy/runme.sh b/test/integration/targets/ansible-galaxy/runme.sh index 0af7f20f7b..61cee57b71 100755 --- a/test/integration/targets/ansible-galaxy/runme.sh +++ b/test/integration/targets/ansible-galaxy/runme.sh @@ -290,6 +290,20 @@ pushd "${role_testdir}" popd # ${role_testdir} rm -rf "${role_testdir}" +f_ansible_galaxy_status \ + "Test role with non-ascii characters" + +role_testdir=$(mktemp -d) +pushd "${role_testdir}" + + mkdir nonascii + ansible-galaxy role init --init-path ./nonascii nonascii + touch nonascii/ÅÑŚÌβŁÈ.txt + tar czvf nonascii.tar.gz nonascii + ansible-galaxy role install -p ./roles nonascii.tar.gz + +popd # ${role_testdir} +rm -rf "${role_testdir}" ################################# # ansible-galaxy collection tests |