From 50705c568303e0b938c7620c9838a386b723eb3e Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Wed, 7 Oct 2009 22:11:48 +0200 Subject: [PATCH] jscript: Fixed escaped characters processing. --- dlls/jscript/lex.c | 16 +++++++++------- dlls/jscript/tests/api.js | 8 ++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/dlls/jscript/lex.c b/dlls/jscript/lex.c index 680ce557274..43089d3e210 100644 --- a/dlls/jscript/lex.c +++ b/dlls/jscript/lex.c @@ -287,7 +287,7 @@ static BOOL unescape(WCHAR *str) i = hex_to_int(*++p); if(i == -1) return FALSE; - c += 1 << 4; + c += i << 4; i = hex_to_int(*++p); if(i == -1) @@ -297,13 +297,15 @@ static BOOL unescape(WCHAR *str) default: if(isdigitW(*p)) { c = *p++ - '0'; - while(isdigitW(*p)) - c = c*10 + (*p++ - '0'); - *pd++ = c; - continue; + if(isdigitW(*p)) { + c = c*8 + (*p++ - '0'); + if(isdigitW(*p)) + c = c*8 + (*p++ - '0'); + } + p--; } - - c = *p; + else + c = *p; } *pd++ = c; diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js index ea1a5b2fb19..be85566f587 100644 --- a/dlls/jscript/tests/api.js +++ b/dlls/jscript/tests/api.js @@ -66,6 +66,8 @@ tmp = escape("a1b c!d+e@*-_+./,"); ok(tmp === "a1b%20c%21d+e@*-_+./%2C", "escape('a1b c!d+e@*-_+./,') = " + tmp); tmp = escape(); ok(tmp === "undefined", "escape() = " + tmp); +tmp = escape('\u1234\123\xf3'); +ok(tmp == "%u1234S%F3", "escape('\u1234\123\xf3') = " + tmp); tmp = unescape("abc"); ok(tmp === "abc", "unescape('abc') = " + tmp); @@ -201,6 +203,12 @@ tmp = "abc".charCodeAt(true); ok(tmp === 0x62, "'abc'.charCodeAt(true) = " + tmp); tmp = "abc".charCodeAt(0,2); ok(tmp === 0x61, "'abc'.charCodeAt(0,2) = " + tmp); +tmp = "\u49F4".charCodeAt(0); +ok(tmp === 0x49F4, "'\u49F4'.charCodeAt(0) = " + tmp); +tmp = "\052".charCodeAt(0); +ok(tmp === 0x2A, "'\052'.charCodeAt(0) = " + tmp); +tmp = "\xa2".charCodeAt(0); +ok(tmp === 0xA2, "'\xa2'.charCodeAt(0) = " + tmp); tmp = "abcd".substring(1,3); ok(tmp === "bc", "'abcd'.substring(1,3) = " + tmp); -- 2.11.4.GIT