diff -r 197d703fb23e Tools/i18n/msgfmt.py --- a/Tools/i18n/msgfmt.py Sun Oct 30 20:39:24 2011 +0100 +++ b/Tools/i18n/msgfmt.py Mon Oct 31 10:57:41 2011 +0100 @@ -29,6 +29,7 @@ import getopt import struct import array +import re from email.parser import HeaderParser __version__ = "1.1" @@ -180,17 +181,20 @@ l = l.strip() if not l: continue - # XXX: Does this always follow Python escape semantics? - l = eval(l) - if section == ID: - msgid += l.encode(encoding) - elif section == STR: - msgstr += l.encode(encoding) - else: + # Strip leading and trailing double quote + l = l[1:-1] + # Check that entry is valid + if re.search(r'([^\\]|^)"', l) or section not in (ID, STR): print('Syntax error on %s:%d' % (infile, lno), \ 'before:', file=sys.stderr) print(l, file=sys.stderr) sys.exit(1) + + if section == ID: + msgid += l.encode(encoding) + else: + msgstr += l.encode(encoding) + # Add last entry if section == STR: add(msgid, msgstr, fuzzy)