web/ldt/ldt_utils/views.py
changeset 30 81d408373dde
parent 27 f81da251d0aa
--- a/web/ldt/ldt_utils/views.py	Fri Jun 11 00:25:17 2010 +0200
+++ b/web/ldt/ldt_utils/views.py	Sat Jun 12 00:33:37 2010 +0200
@@ -7,6 +7,7 @@
 from django.conf import settings
 from django.core import serializers
 from django.utils import simplejson
+from django.utils.html import escape
 from fileimport import *
 from forms import LdtImportForm, LdtAddForm, SearchForm, AddProjectForm, CopyProjectForm
 from ldt.core.models import Owner
@@ -221,6 +222,11 @@
         indent = int(indent)
     
     callback = request.REQUEST.get("callback")
+    escape_str = request.REQUEST.get("escape")
+    escape_bool = False
+    if escape_str:
+        escape_bool = {'true': True, 'false': False, "0": False, "1": True}.get(escape_str.lower())
+        
         
     ps = ProjectSerializer(project)
     project_dict = ps.serialize_to_cinelab()
@@ -230,6 +236,9 @@
     if callback is not None:
         json_str = "%s(%s)" % (callback,json_str)
     
+    if escape_bool:
+        json_str = escape(json_str)
+    
     resp.write(json_str)
 
     return resp