String array acces
Harri Porten
porten at froglogic.com
Sat Feb 21 21:43:35 CET 2004
Hi,
I just looked at a diff in string_object.cpp that looks suspicious.
--- string_object.cpp Sat Feb 21 21:34:53 2004
+++ JavaScriptCore/kjs/string_object.cpp Tue Feb 3 00:03:31 2004
@@ -60,10 +60,10 @@
if (ok) {
const UString s = internalValue().toString(exec);
const unsigned length = s.size();
- if (index < length) {
- const UChar c = s[index];
- return String(UString(&c, 1));
- }
+ if (index >= length)
+ return Undefined();
+ const UChar c = s[index];
+ return String(UString(&c, 1));
}
return ObjectImp::get(exec, propertyName);
Out of bounds array access are always answered with "undefined". This
little example
var s = "foo";
String.prototype[10] = "x";
document.write(s[10]);
gives "x" in Konq and Mozilla, though. Could anyone try this with IE,
please?
Harri.
More information about the Khtml-devel
mailing list