actually close #344401 by removing unprintable characters stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 07 Jul 2009 13:25:24 +0200
branchstable
changeset 2311 f178182b1305
parent 2310 80fcdfbb8eed
child 2312 af4d8f75c5db
actually close #344401 by removing unprintable characters
ext/rest.py
--- a/ext/rest.py	Tue Jul 07 13:15:46 2009 +0200
+++ b/ext/rest.py	Tue Jul 07 13:25:24 2009 +0200
@@ -29,7 +29,7 @@
 from docutils.parsers.rst import Parser, states, directives
 from docutils.parsers.rst.roles import register_canonical_role, set_classes
 
-from logilab.mtconverter import html_escape
+from logilab.mtconverter import ESC_UCAR_TABLE, ESC_CAR_TABLE, html_escape
 
 from cubicweb.ext.html4zope import Writer
 
@@ -207,8 +207,12 @@
     req = context.req
     if isinstance(data, unicode):
         encoding = 'unicode'
+        # remove unprintable characters unauthorized in xml
+        data = data.translate(ESC_UCAR_TABLE)
     else:
         encoding = req.encoding
+        # remove unprintable characters unauthorized in xml
+        data = data.translate(ESC_CAR_TABLE)
     settings = {'input_encoding': encoding, 'output_encoding': 'unicode',
                 'warning_stream': StringIO(), 'context': context,
                 # dunno what's the max, severe is 4, and we never want a crash