Quantcast
Channel: Mako: Ticket Query
Viewing all articles
Browse latest Browse all 38

#220: extract_messages fails on backslash-escaped quotes at the end of a string

$
0
0

If a translation string ends in an escaped quote (\") or apostrophe (\) the message extractors will throw an error.

Repro case:

  1. Create a mako template containing this:
    ${_("\"")}
    ${_('\'')}
    
  1. Set up babel and extract messages:
    $ python setup.py extract_messages
    Traceback (most recent call last):
      File "setup.py", line 67, in <module>
        """,
      File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
        dist.run_commands()
      File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/home/nick/virtualenv/local/lib/python2.7/site-packages/babel/messages/frontend.py", line 314, in run
        for filename, lineno, message, comments in extracted:
      File "/home/nick/virtualenv/local/lib/python2.7/site-packages/babel/messages/extract.py", line 171, in extract_from_dir
        strip_comment_tags):
      File "/home/nick/virtualenv/local/lib/python2.7/site-packages/babel/messages/extract.py", line 201, in extract_from_file
        strip_comment_tags))
      File "/home/nick/virtualenv/local/lib/python2.7/site-packages/babel/messages/extract.py", line 285, in extract
        for lineno, funcname, messages, comments in results:
      File "/usr/lib/python2.7/dist-packages/mako/ext/babelplugin.py", line 29, in extract
        input_encoding=encoding).parse()
      File "/usr/lib/python2.7/dist-packages/mako/lexer.py", line 209, in parse
        if self.match_expression():
      File "/usr/lib/python2.7/dist-packages/mako/lexer.py", line 360, in match_expression
        text, end = self.parse_until_text(r'\|', r'}')
      File "/usr/lib/python2.7/dist-packages/mako/lexer.py", line 105, in parse_until_text
        **self.exception_kwargs)
    mako.exceptions.SyntaxException: Unmatched '"' at line: 1 char: 8
    

Viewing all articles
Browse latest Browse all 38

Trending Articles