From 9bd2d1ec908552b11bdb9192103ec8f1c4cfb529 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 9 Nov 2021 06:29:09 +0100 Subject: [PATCH] Better handling of base64-encoded values in xattr module (#3675) (#3678) * Fix exception in xattr module when existing extended attribute's value contains non-printable characters and the base64-encoded string contains a '=' sign * Added changelog fragment for #3675 * Apply suggestions from code review Co-authored-by: Felix Fontein (cherry picked from commit 2f0ae0408d953307a04dd7a64772060e24fd9efc) Co-authored-by: sc-anssi --- changelogs/fragments/3675-xattr-handle-base64-values.yml | 3 +++ plugins/modules/files/xattr.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/3675-xattr-handle-base64-values.yml diff --git a/changelogs/fragments/3675-xattr-handle-base64-values.yml b/changelogs/fragments/3675-xattr-handle-base64-values.yml new file mode 100644 index 0000000000..e74a2afedd --- /dev/null +++ b/changelogs/fragments/3675-xattr-handle-base64-values.yml @@ -0,0 +1,3 @@ +bugfixes: + - xattr - fix exception caused by ``_run_xattr()`` raising a ``ValueError`` + due to a mishandling of base64-encoded value (https://github.com/ansible-collections/community.general/issues/3673). diff --git a/plugins/modules/files/xattr.py b/plugins/modules/files/xattr.py index f862dd720b..21d71170d1 100644 --- a/plugins/modules/files/xattr.py +++ b/plugins/modules/files/xattr.py @@ -158,7 +158,7 @@ def _run_xattr(module, cmd, check_rc=True): if line.startswith('#') or line == '': pass elif '=' in line: - (key, val) = line.split('=') + (key, val) = line.split('=', 1) result[key] = val.strip('"') else: result[line] = ''