Skip to content

Commit f4c9e06

Browse files
author
Toshiaki Nakatsu
committed
fixed unescapeString in the same manner as google chrome.
Trailing space is unicode terminator, to be deleted. 'hei\DF en' -> 'heißen' 'hei\00DF en' -> 'heißen' 'hei\0000DF en' -> 'heißen' Six characters of the unicode without terminator. 'hei\0000DFen' -> 'heißen' Non hex-character is unicode terminator, to be passed. 'hei\DFt' -> 'heißt'
1 parent d315d8d commit f4c9e06

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/parseValues.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,22 @@ function endSpacingMatch(match) {
2323
}
2424

2525
function unescapeString(content) {
26-
return content.replace(/\\(?:([a-fA-F0-9]{1,6})|(.))/g, function(all, unicode, otherCharacter) {
27-
if (otherCharacter) {
28-
return otherCharacter;
29-
}
30-
26+
function conv(all, unicode) {
3127
var C = parseInt(unicode, 16);
3228
if(C < 0x10000) {
3329
return String.fromCharCode(C);
3430
} else {
3531
return String.fromCharCode(Math.floor((C - 0x10000) / 0x400) + 0xD800) +
3632
String.fromCharCode((C - 0x10000) % 0x400 + 0xDC00);
3733
}
38-
});
34+
}
35+
36+
return content
37+
.replace(/\\([A-F0-9]{1,6}) /gi, conv)
38+
.replace(/\\([A-F0-9]{6})/gi, conv)
39+
.replace(/\\([A-F0-9]{1,5})(?![A-F0-9])/gi, conv)
40+
.replace(/\\(.)/g, "$1")
41+
;
3942
}
4043

4144
function stringMatch(match, content) {

0 commit comments

Comments
 (0)