diff --git a/ara/server/settings.py b/ara/server/settings.py index e24f45f6..f7734628 100644 --- a/ara/server/settings.py +++ b/ara/server/settings.py @@ -230,6 +230,7 @@ REST_FRAMEWORK = { "DEFAULT_AUTHENTICATION_CLASSES": ("rest_framework.authentication.BasicAuthentication",), "DEFAULT_PERMISSION_CLASSES": ("ara.api.auth.APIAccessPermission",), "TEST_REQUEST_DEFAULT_FORMAT": "json", + "UNICODE_JSON": False, } ARA_SETTINGS = os.getenv("ARA_SETTINGS", DEFAULT_SETTINGS) diff --git a/ara/ui/views.py b/ara/ui/views.py index ab3925eb..8add9ce4 100644 --- a/ara/ui/views.py +++ b/ara/ui/views.py @@ -1,3 +1,5 @@ +import codecs + from rest_framework import generics from rest_framework.renderers import TemplateHTMLRenderer from rest_framework.response import Response @@ -90,6 +92,8 @@ class Result(generics.RetrieveAPIView): template_name = "result.html" def get(self, request, *args, **kwargs): + # Results can contain a wide array of non-ascii or binary characters, escape them + codecs.register_error("strict", codecs.lookup_error("surrogateescape")) result = self.get_object() serializer = serializers.DetailedResultSerializer(result) return Response({"result": serializer.data}) diff --git a/tests/integration/smoke.yaml b/tests/integration/smoke.yaml index e4e4b3dd..23017337 100644 --- a/tests/integration/smoke.yaml +++ b/tests/integration/smoke.yaml @@ -65,6 +65,6 @@ - untag - verytag - - name: Echo a binary string + - name: Echo the �abc binary string command: echo -e '\x80abc' changed_when: false