Comparing version 0.2.11 to 0.2.12
@@ -122,4 +122,28 @@ var fs = require('fs'); | ||
string = string.replace(/^[^"]*"|"$/g, ''); | ||
string = string.replace(/\\"/g, '"'); | ||
string = string.replace(/\\\\/g, '\\'); | ||
string = string.replace(/\\([abtnvfr'"\\?]|([0-7]{3})|x([0-9a-fA-F]{2}))/g, function (match, esc, oct, hex) { | ||
if (oct) { | ||
return String.fromCharCode(parseInt(oct, 8)); | ||
} | ||
if (hex) { | ||
return String.fromCharCode(parseInt(hex, 16)); | ||
} | ||
switch (esc) { | ||
case 'a': | ||
return '\x07'; | ||
case 'b': | ||
return '\b'; | ||
case 't': | ||
return '\t'; | ||
case 'n': | ||
return '\n'; | ||
case 'v': | ||
return '\v'; | ||
case 'f': | ||
return '\f'; | ||
case 'r': | ||
return '\r'; | ||
default: | ||
return esc; | ||
} | ||
}); | ||
return string; | ||
@@ -216,4 +240,23 @@ } | ||
var _escape = function (string) { | ||
string = string.replace(/\\/g, '\\\\'); | ||
return string.replace(/"/g, '\\"'); | ||
// don't unescape \n, since string can never contain it | ||
// since split('\n') is called on it | ||
string = string.replace(/[\x07\b\t\v\f\r"\\]/g, function (match) { | ||
switch (match) { | ||
case '\x07': | ||
return '\\a'; | ||
case '\b': | ||
return '\\b'; | ||
case '\t': | ||
return '\\t'; | ||
case '\v': | ||
return '\\v'; | ||
case '\f': | ||
return '\\f'; | ||
case '\r': | ||
return '\\r'; | ||
default: | ||
return '\\' + match; | ||
} | ||
}); | ||
return string; | ||
}; | ||
@@ -267,2 +310,6 @@ | ||
var processed = _process(keyword, text); | ||
//handle \n in single-line texts (can not be handled in _escape) | ||
for (var i = 1; i < processed.length - 1; i++) { | ||
processed[i] = processed[i].slice(0, -1) + '\\n"'; | ||
} | ||
lines = lines.concat(mkObsolete + processed.join('\n' + mkObsolete)); | ||
@@ -269,0 +316,0 @@ } |
{ | ||
"name": "pofile", | ||
"description": "Parse and serialize Gettext PO files.", | ||
"version": "0.2.11", | ||
"version": "0.2.12", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Ruben Vermeersch", |
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
18163
320