fix a unicode bug in the stdout endpoint when ?content_encoding=base64

see: https://github.com/ansible/awx/issues/1042
This commit is contained in:
Ryan Petrello
2018-01-25 15:53:43 -05:00
parent a56370fed5
commit a15e257b9e
2 changed files with 19 additions and 1 deletions

View File

@@ -4641,7 +4641,7 @@ class UnifiedJobStdout(RetrieveAPIView):
return Response(mark_safe(data))
if target_format == 'json':
if content_encoding == 'base64' and content_format == 'ansi':
return Response({'range': {'start': start, 'end': end, 'absolute_end': absolute_end}, 'content': b64encode(content)})
return Response({'range': {'start': start, 'end': end, 'absolute_end': absolute_end}, 'content': b64encode(content.encode('utf-8'))})
elif content_format == 'html':
return Response({'range': {'start': start, 'end': end, 'absolute_end': absolute_end}, 'content': body})
return Response(data)