Piotr Caban : jscript: Fixed escaped characters processing.

Alexandre Julliard julliard at winehq.org
Thu Oct 8 08:57:13 CDT 2009


Module: wine
Branch: master
Commit: 50705c568303e0b938c7620c9838a386b723eb3e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=50705c568303e0b938c7620c9838a386b723eb3e

Author: Piotr Caban <piotr.caban at gmail.com>
Date:   Wed Oct  7 22:11:48 2009 +0200

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 680ce55..43089d3 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 ea1a5b2..be85566 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);




More information about the wine-cvs mailing list