gettext-parser
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -46,2 +46,3 @@ 'use strict'; | ||
this._state = this.states.none; | ||
this._lineNumber = 1; | ||
@@ -124,3 +125,4 @@ if (typeof fileContents === 'string') { | ||
whitespace: /\s/, | ||
key: /[\w\-[\]]/ | ||
key: /[\w\-[\]]/, | ||
keyNames: /^(?:msgctxt|msgid(?:_plural)?|msgstr(?:\[\d+])?)$/ | ||
}; | ||
@@ -138,2 +140,7 @@ | ||
chr = chunk.charAt(i); | ||
if (chr === '\n') { | ||
this._lineNumber += 1; | ||
} | ||
switch (this._state) { | ||
@@ -202,2 +209,7 @@ case this.states.none: | ||
if (!chr.match(this.symbols.key)) { | ||
if (!this._node.value.match(this.symbols.keyNames)) { | ||
var err = new SyntaxError('Error parsing PO data: Invalid key name "' + this._node.value + '" at line ' + this._lineNumber + '. This can be caused by an unescaped quote character in a msgid or msgstr value.'); | ||
err.lineNumber = this._lineNumber; | ||
throw err; | ||
} | ||
this._state = this.states.none; | ||
@@ -504,3 +516,10 @@ i--; | ||
if (chunk.length) { | ||
this._parser._lexer(this._parser._toString(chunk)); | ||
try { | ||
this._parser._lexer(this._parser._toString(chunk)); | ||
} catch (error) { | ||
setImmediate(function () { | ||
done(error); | ||
}); | ||
return; | ||
} | ||
} | ||
@@ -526,3 +545,10 @@ | ||
if (chunk) { | ||
this._parser._lexer(this._parser._toString(chunk)); | ||
try { | ||
this._parser._lexer(this._parser._toString(chunk)); | ||
} catch (error) { | ||
setImmediate(function () { | ||
done(error); | ||
}); | ||
return; | ||
} | ||
} | ||
@@ -529,0 +555,0 @@ |
{ | ||
"name": "gettext-parser", | ||
"description": "Parse and compile gettext po and mo files to/from json, nothing more, nothing less", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"author": "Andris Reinman", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48492
1191