From 43269c925531ad9baa84440a1b20d268e10adf7b Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 9 Nov 2021 06:28:35 +0100 Subject: [PATCH] Better handling of base64-encoded values in xattr module (#3675) (#3676) * 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 7691f30905..9321602ddb 100644 --- a/plugins/modules/files/xattr.py +++ b/plugins/modules/files/xattr.py @@ -157,7 +157,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] = ''