зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1034627 part 3 - Fix SandboxDump, AccessCheck.cpp to work with Latin1 strings and nursery strings. r=bholley
This commit is contained in:
Родитель
edbd6779df
Коммит
b986e6ec0f
|
@ -98,13 +98,8 @@ SandboxDump(JSContext *cx, unsigned argc, jsval *vp)
|
|||
if (!str)
|
||||
return false;
|
||||
|
||||
size_t length;
|
||||
const jschar *chars = JS_GetStringCharsZAndLength(cx, str, &length);
|
||||
if (!chars)
|
||||
return false;
|
||||
|
||||
nsDependentString wstr(chars, length);
|
||||
char *cstr = ToNewUTF8String(wstr);
|
||||
JSAutoByteString utf8str;
|
||||
char *cstr = utf8str.encodeUtf8(cx, str);
|
||||
if (!cstr)
|
||||
return false;
|
||||
|
||||
|
@ -123,7 +118,6 @@ SandboxDump(JSContext *cx, unsigned argc, jsval *vp)
|
|||
|
||||
fputs(cstr, stdout);
|
||||
fflush(stdout);
|
||||
NS_Free(cstr);
|
||||
args.rval().setBoolean(true);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ AccessCheck::getPrincipal(JSCompartment *compartment)
|
|||
}
|
||||
|
||||
#define NAME(ch, str, cases) \
|
||||
case ch: if (!strcmp(name, str)) switch (propChars[0]) { cases }; break;
|
||||
case ch: if (!strcmp(name, str)) switch (propChar0) { cases }; break;
|
||||
#define PROP(ch, actions) case ch: { actions }; break;
|
||||
#define RW(str) if (JS_FlatStringEqualsAscii(prop, str)) return true;
|
||||
#define R(str) if (!set && JS_FlatStringEqualsAscii(prop, str)) return true;
|
||||
|
@ -103,18 +103,18 @@ AccessCheck::getPrincipal(JSCompartment *compartment)
|
|||
static bool
|
||||
IsPermitted(const char *name, JSFlatString *prop, bool set)
|
||||
{
|
||||
size_t propLength;
|
||||
const jschar *propChars =
|
||||
JS_GetInternedStringCharsAndLength(JS_FORGET_STRING_FLATNESS(prop), &propLength);
|
||||
size_t propLength = JS_GetStringLength(JS_FORGET_STRING_FLATNESS(prop));
|
||||
if (!propLength)
|
||||
return false;
|
||||
|
||||
jschar propChar0 = JS_GetFlatStringCharAt(prop, 0);
|
||||
switch (name[0]) {
|
||||
NAME('L', "Location",
|
||||
PROP('h', W("href"))
|
||||
PROP('r', R("replace")))
|
||||
case 'W':
|
||||
if (!strcmp(name, "Window"))
|
||||
return dom::WindowBinding::IsPermitted(prop, propChars[0], set);
|
||||
return dom::WindowBinding::IsPermitted(prop, propChar0, set);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
@ -292,14 +292,15 @@ ExposedPropertiesOnly::check(JSContext *cx, JSObject *wrapperArg, jsid idArg, Wr
|
|||
return false;
|
||||
}
|
||||
|
||||
JSString *str = desc.value().toString();
|
||||
size_t length;
|
||||
const jschar *chars = JS_GetStringCharsAndLength(cx, str, &length);
|
||||
if (!chars)
|
||||
JSFlatString *flat = JS_FlattenString(cx, desc.value().toString());
|
||||
if (!flat)
|
||||
return false;
|
||||
|
||||
size_t length = JS_GetStringLength(JS_FORGET_STRING_FLATNESS(flat));
|
||||
|
||||
for (size_t i = 0; i < length; ++i) {
|
||||
switch (chars[i]) {
|
||||
jschar ch = JS_GetFlatStringCharAt(flat, i);
|
||||
switch (ch) {
|
||||
case 'r':
|
||||
if (access & READ) {
|
||||
EnterAndThrow(cx, wrapper, "duplicate 'readable' property flag");
|
||||
|
|
Загрузка…
Ссылка в новой задаче