Sebastian Lackner : jscript: Properly handle \0 characters in String to{Lower, Upper}Case methods.
Alexandre Julliard
julliard at winehq.org
Fri Sep 9 10:09:03 CDT 2016
Module: wine
Branch: master
Commit: 54e6736032c59a3978918c3d3ac2ea8347f5d3a7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=54e6736032c59a3978918c3d3ac2ea8347f5d3a7
Author: Sebastian Lackner <sebastian at fds-team.de>
Date: Thu Sep 8 23:52:19 2016 +0200
jscript: Properly handle \0 characters in String to{Lower,Upper}Case methods.
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/jscript/string.c | 12 ++++++++----
dlls/jscript/tests/api.js | 4 ++++
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c
index 80c3dd8..40aa552 100644
--- a/dlls/jscript/string.c
+++ b/dlls/jscript/string.c
@@ -1402,17 +1402,19 @@ static HRESULT String_toLowerCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return hres;
if(r) {
+ unsigned len = jsstr_length(str);
jsstr_t *ret;
WCHAR *buf;
- ret = jsstr_alloc_buf(jsstr_length(str), &buf);
+ ret = jsstr_alloc_buf(len, &buf);
if(!ret) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
jsstr_flush(str, buf);
- strlwrW(buf);
+ for (; len--; buf++) *buf = tolowerW(*buf);
+
*r = jsval_string(ret);
}
jsstr_release(str);
@@ -1432,17 +1434,19 @@ static HRESULT String_toUpperCase(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return hres;
if(r) {
+ unsigned len = jsstr_length(str);
jsstr_t *ret;
WCHAR *buf;
- ret = jsstr_alloc_buf(jsstr_length(str), &buf);
+ ret = jsstr_alloc_buf(len, &buf);
if(!ret) {
jsstr_release(str);
return E_OUTOFMEMORY;
}
jsstr_flush(str, buf);
- struprW(buf);
+ for (; len--; buf++) *buf = toupperW(*buf);
+
*r = jsval_string(ret);
}
jsstr_release(str);
diff --git a/dlls/jscript/tests/api.js b/dlls/jscript/tests/api.js
index c7f2bcd..e7b55fc 100644
--- a/dlls/jscript/tests/api.js
+++ b/dlls/jscript/tests/api.js
@@ -661,6 +661,8 @@ tmp = "tEsT".toLowerCase();
ok(tmp === "test", "''.toLowerCase() = " + tmp);
tmp = "tEsT".toLowerCase(3);
ok(tmp === "test", "''.toLowerCase(3) = " + tmp);
+tmp = ("tE" + String.fromCharCode(0) + "sT").toLowerCase();
+ok(tmp === "te" + String.fromCharCode(0) + "st", "''.toLowerCase() = " + tmp);
tmp = "".toUpperCase();
ok(tmp === "", "''.toUpperCase() = " + tmp);
@@ -672,6 +674,8 @@ tmp = "tEsT".toUpperCase();
ok(tmp === "TEST", "''.toUpperCase() = " + tmp);
tmp = "tEsT".toUpperCase(3);
ok(tmp === "TEST", "''.toUpperCase(3) = " + tmp);
+tmp = ("tE" + String.fromCharCode(0) + "sT").toUpperCase();
+ok(tmp === "TE" + String.fromCharCode(0) + "ST", "''.toUpperCase() = " + tmp);
tmp = "".anchor();
ok(tmp === "<A NAME=\"undefined\"></A>", "''.anchor() = " + tmp);
More information about the wine-cvs
mailing list