Fixed unescaping of all escaped C String characters.
Signed-off-by: Julian Bäume <julian@svg4all.de> Conflicts: lib/po.js
This commit is contained in:
parent
d8fc514359
commit
4cfebdee80
28
lib/po.js
28
lib/po.js
@ -119,8 +119,32 @@ PO.parse = function (data) {
|
||||
function extract(string) {
|
||||
string = trim(string);
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user