[FIX] ir_translation: remove control characters from translations
authorDenis Ledoux <dle@odoo.com>
Fri, 3 Oct 2014 09:20:19 +0000 (11:20 +0200)
committerDenis Ledoux <dle@odoo.com>
Fri, 3 Oct 2014 09:20:19 +0000 (11:20 +0200)
This is possible that control characters (such as line returns) are inserted wrongly in translations
These should not influence on the web interface

openerp/addons/base/ir/ir_translation.py

index cdbec59..f8eecc7 100644 (file)
@@ -20,6 +20,7 @@
 ##############################################################################
 
 import logging
+import unicodedata
 
 from openerp import tools
 import openerp.modules
@@ -335,10 +336,11 @@ class ir_translation(osv.osv):
                            AND name=%s""",
                     (lang or '', types, tools.ustr(name)))
         res = cr.fetchone()
-        trad = res and res[0] or u''
+        trad = res and tools.ustr(res[0]) or u''
         if source and not trad:
             return tools.ustr(source)
-        return trad
+        # Remove control characters
+        return filter(lambda c: unicodedata.category(c) != 'Cc', trad)
 
     def create(self, cr, uid, vals, context=None):
         if context is None: