diff --git a/lib/parseValues.js b/lib/parseValues.js index 97be01b..e8b1cf6 100644 --- a/lib/parseValues.js +++ b/lib/parseValues.js @@ -23,11 +23,7 @@ function endSpacingMatch(match) { } function unescapeString(content) { - return content.replace(/\\(?:([a-fA-F0-9]{1,6})|(.))/g, function(all, unicode, otherCharacter) { - if (otherCharacter) { - return otherCharacter; - } - + function conv(all, unicode) { var C = parseInt(unicode, 16); if(C < 0x10000) { return String.fromCharCode(C); @@ -35,7 +31,14 @@ function unescapeString(content) { return String.fromCharCode(Math.floor((C - 0x10000) / 0x400) + 0xD800) + String.fromCharCode((C - 0x10000) % 0x400 + 0xDC00); } - }); + } + + return content + .replace(/\\([A-F0-9]{1,6}) /gi, conv) + .replace(/\\([A-F0-9]{6})/gi, conv) + .replace(/\\([A-F0-9]{1,5})(?![A-F0-9])/gi, conv) + .replace(/\\(.)/g, "$1") + ; } function stringMatch(match, content) {