From 22ee89f0f3fa295a265547336f837261bb919f34 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Sat, 28 Jan 2012 14:38:06 +0000 Subject: Tidy up auto-escaping. --- djangorestframework/templates/renderer.html | 2 +- djangorestframework/templates/renderer.txt | 4 ++-- djangorestframework/views.py | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/djangorestframework/templates/renderer.html b/djangorestframework/templates/renderer.html index ff761023..5faa8b3e 100644 --- a/djangorestframework/templates/renderer.html +++ b/djangorestframework/templates/renderer.html @@ -50,7 +50,7 @@

{{ name }}

-

{% autoescape off %}{{ description }}{% endautoescape %}

+

{{ description }}

{{ response.status }} {{ response.status_text }}{% autoescape off %}
 {% for key, val in response.headers.items %}{{ key }}: {{ val|urlize_quoted_links }}
diff --git a/djangorestframework/templates/renderer.txt b/djangorestframework/templates/renderer.txt
index 5be8c117..b584952c 100644
--- a/djangorestframework/templates/renderer.txt
+++ b/djangorestframework/templates/renderer.txt
@@ -1,8 +1,8 @@
-{{ name }}
+{% autoescape off %}{{ name }}
 
 {{ description }}
 
-{% autoescape off %}HTTP/1.0 {{ response.status }} {{ response.status_text }}
+HTTP/1.0 {{ response.status }} {{ response.status_text }}
 {% for key, val in response.headers.items %}{{ key }}: {{ val }}
 {% endfor %}
 {{ content }}{% endautoescape %}
diff --git a/djangorestframework/views.py b/djangorestframework/views.py
index 88d81d25..32d2437c 100644
--- a/djangorestframework/views.py
+++ b/djangorestframework/views.py
@@ -36,6 +36,7 @@ def _remove_trailing_string(content, trailing):
         return content[:-len(trailing)]
     return content
 
+
 def _remove_leading_indent(content):
     """
     Remove leading indent from a block of text.
@@ -50,6 +51,7 @@ def _remove_leading_indent(content):
         return re.sub(re.compile(whitespace_pattern, re.MULTILINE), '', content)
     return content
 
+
 def _camelcase_to_spaces(content):
     """
     Translate 'CamelCaseNames' to 'Camel Case Names'.
@@ -161,9 +163,10 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
 
     def markup_description(self, description):
         if apply_markdown:
-            return apply_markdown(description)
+            description = apply_markdown(description)
         else:
-            return mark_safe(escape(description).replace('\n', '
')) + description = escape(description).replace('\n', '
') + return mark_safe(description) def http_method_not_allowed(self, request, *args, **kwargs): """ -- cgit v1.2.3