Commit 54e67360 authored by Sebastian Lackner's avatar Sebastian Lackner Committed by Alexandre Julliard

jscript: Properly handle \0 characters in String to{Lower,Upper}Case methods.

parent cd5ea761
...@@ -1402,17 +1402,19 @@ static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags ...@@ -1402,17 +1402,19 @@ static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return hres; return hres;
if(r) { if(r) {
unsigned len = jsstr_length(str);
jsstr_t *ret; jsstr_t *ret;
WCHAR *buf; WCHAR *buf;
ret = jsstr_alloc_buf(jsstr_length(str), &buf); ret = jsstr_alloc_buf(len, &buf);
if(!ret) { if(!ret) {
jsstr_release(str); jsstr_release(str);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
jsstr_flush(str, buf); jsstr_flush(str, buf);
strlwrW(buf); for (; len--; buf++) *buf = tolowerW(*buf);
*r = jsval_string(ret); *r = jsval_string(ret);
} }
jsstr_release(str); jsstr_release(str);
...@@ -1432,17 +1434,19 @@ static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags ...@@ -1432,17 +1434,19 @@ static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return hres; return hres;
if(r) { if(r) {
unsigned len = jsstr_length(str);
jsstr_t *ret; jsstr_t *ret;
WCHAR *buf; WCHAR *buf;
ret = jsstr_alloc_buf(jsstr_length(str), &buf); ret = jsstr_alloc_buf(len, &buf);
if(!ret) { if(!ret) {
jsstr_release(str); jsstr_release(str);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
jsstr_flush(str, buf); jsstr_flush(str, buf);
struprW(buf); for (; len--; buf++) *buf = toupperW(*buf);
*r = jsval_string(ret); *r = jsval_string(ret);
} }
jsstr_release(str); jsstr_release(str);
......
...@@ -661,6 +661,8 @@ tmp = "tEsT".toLowerCase(); ...@@ -661,6 +661,8 @@ tmp = "tEsT".toLowerCase();
ok(tmp === "test", "''.toLowerCase() = " + tmp); ok(tmp === "test", "''.toLowerCase() = " + tmp);
tmp = "tEsT".toLowerCase(3); tmp = "tEsT".toLowerCase(3);
ok(tmp === "test", "''.toLowerCase(3) = " + tmp); ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
tmp = ("tE" + String.fromCharCode(0) + "sT").toLowerCase();
ok(tmp === "te" + String.fromCharCode(0) + "st", "''.toLowerCase() = " + tmp);
tmp = "".toUpperCase(); tmp = "".toUpperCase();
ok(tmp === "", "''.toUpperCase() = " + tmp); ok(tmp === "", "''.toUpperCase() = " + tmp);
...@@ -672,6 +674,8 @@ tmp = "tEsT".toUpperCase(); ...@@ -672,6 +674,8 @@ tmp = "tEsT".toUpperCase();
ok(tmp === "TEST", "''.toUpperCase() = " + tmp); ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
tmp = "tEsT".toUpperCase(3); tmp = "tEsT".toUpperCase(3);
ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp); ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
tmp = ("tE" + String.fromCharCode(0) + "sT").toUpperCase();
ok(tmp === "TE" + String.fromCharCode(0) + "ST", "''.toUpperCase() = " + tmp);
tmp = "".anchor(); tmp = "".anchor();
ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp); ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment