mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 17:28:51 -03:30
Merge pull request #3118 from ryanpetrello/fix-3108
work around a bug in Django that breaks the stdout HTML view in py3 Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
# Copyright (c) 2015 Ansible, Inc.
|
# Copyright (c) 2015 Ansible, Inc.
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
|
|
||||||
|
from django.utils.safestring import SafeText
|
||||||
|
|
||||||
# Django REST Framework
|
# Django REST Framework
|
||||||
from rest_framework import renderers
|
from rest_framework import renderers
|
||||||
from rest_framework.request import override_method
|
from rest_framework.request import override_method
|
||||||
@@ -18,6 +20,19 @@ class BrowsableAPIRenderer(renderers.BrowsableAPIRenderer):
|
|||||||
return renderers.JSONRenderer()
|
return renderers.JSONRenderer()
|
||||||
return renderer
|
return renderer
|
||||||
|
|
||||||
|
def get_content(self, renderer, data, accepted_media_type, renderer_context):
|
||||||
|
if isinstance(data, SafeText):
|
||||||
|
# Older versions of Django (pre-2.0) have a py3 bug which causes
|
||||||
|
# bytestrings marked as "safe" to not actually get _treated_ as
|
||||||
|
# safe; this causes certain embedded strings (like the stdout HTML
|
||||||
|
# view) to be improperly escaped
|
||||||
|
# see: https://github.com/ansible/awx/issues/3108
|
||||||
|
# https://code.djangoproject.com/ticket/28121
|
||||||
|
return data
|
||||||
|
return super(BrowsableAPIRenderer, self).get_content(renderer, data,
|
||||||
|
accepted_media_type,
|
||||||
|
renderer_context)
|
||||||
|
|
||||||
def get_context(self, data, accepted_media_type, renderer_context):
|
def get_context(self, data, accepted_media_type, renderer_context):
|
||||||
# Store the associated response status to know how to populate the raw
|
# Store the associated response status to know how to populate the raw
|
||||||
# data form.
|
# data form.
|
||||||
|
|||||||
Reference in New Issue
Block a user