From 9169daa3266f8d071d821ee9ac830da95ebf5152 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Wed, 1 Aug 2018 08:44:39 -0400 Subject: [PATCH] \r does not round-trip the local socket, escape and restore on the other side (#43507) --- bin/ansible-connection | 2 ++ lib/ansible/executor/task_executor.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/bin/ansible-connection b/bin/ansible-connection index 9b1ae2cd04..322ccc5a91 100755 --- a/bin/ansible-connection +++ b/bin/ansible-connection @@ -214,6 +214,8 @@ def main(): raise Exception("EOF found before vars data was complete") vars_data += cur_line cur_line = stdin.readline() + # restore escaped loose \r characters + vars_data = vars_data.replace(br'\r', b'\r') if PY3: pc_data = cPickle.loads(init_data, encoding='bytes') diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index 53bddc555f..b91e480742 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -936,6 +936,8 @@ class TaskExecutor: stdin.write(b'\n#END_INIT#\n') src = cPickle.dumps(variables, protocol=0) + # remaining \r fail to round-trip the socket + src = src.replace(b'\r', br'\r') stdin.write(src) stdin.write(b'\n#END_VARS#\n')