[FIX] ir_translation: remove control characters from translations

This is possible that control characters (such as line returns) are inserted wrongly in translations
These should not influence on the web interface
This commit is contained in:
Denis Ledoux 2014-10-03 11:20:19 +02:00
parent b2cb31c0fb
commit 6d4e1cc73e
1 changed files with 4 additions and 2 deletions

View File

@ -20,6 +20,7 @@
############################################################################## ##############################################################################
import logging import logging
import unicodedata
from openerp import tools from openerp import tools
import openerp.modules import openerp.modules
@ -335,10 +336,11 @@ class ir_translation(osv.osv):
AND name=%s""", AND name=%s""",
(lang or '', types, tools.ustr(name))) (lang or '', types, tools.ustr(name)))
res = cr.fetchone() res = cr.fetchone()
trad = res and res[0] or u'' trad = res and tools.ustr(res[0]) or u''
if source and not trad: if source and not trad:
return tools.ustr(source) 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): def create(self, cr, uid, vals, context=None):
if context is None: if context is None: