Fix parser handles textdomain directives incorrectly (#3954)

The problem is that when parsing #textdomain directives, the parser
expects the directive to be at the start of the line. So if the directive
is preceded by spaces or tabs then it is treated as an attribute.

The solution is to strip all spaces and tabs on the left side of the
parsed line string when checking for #textdomain directive.

Closes #3951
This commit is contained in:
Lovens Weche 2019-02-28 04:40:45 -05:00 committed by Gunter Labes
parent 3c3a814224
commit 3a564f7b21

View file

@ -507,8 +507,8 @@ class Parser:
Parse a WML fragment outside of strings.
"""
if not line: return
if line.startswith(b"#textdomain "):
self.textdomain = line[12:].strip().decode("utf8")
if line.lstrip(b" \t").startswith(b"#textdomain "):
self.textdomain = line.lstrip(b" \t")[12:].strip().decode("utf8")
return
if not self.temp_key_nodes:
line = line.lstrip()