зеркало из 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)
|
if (!str)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
size_t length;
|
JSAutoByteString utf8str;
|
||||||
const jschar *chars = JS_GetStringCharsZAndLength(cx, str, &length);
|
char *cstr = utf8str.encodeUtf8(cx, str);
|
||||||
if (!chars)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
nsDependentString wstr(chars, length);
|
|
||||||
char *cstr = ToNewUTF8String(wstr);
|
|
||||||
if (!cstr)
|
if (!cstr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -123,7 +118,6 @@ SandboxDump(JSContext *cx, unsigned argc, jsval *vp)
|
||||||
|
|
||||||
fputs(cstr, stdout);
|
fputs(cstr, stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
NS_Free(cstr);
|
|
||||||
args.rval().setBoolean(true);
|
args.rval().setBoolean(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ AccessCheck::getPrincipal(JSCompartment *compartment)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NAME(ch, str, cases) \
|
#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 PROP(ch, actions) case ch: { actions }; break;
|
||||||
#define RW(str) if (JS_FlatStringEqualsAscii(prop, str)) return true;
|
#define RW(str) if (JS_FlatStringEqualsAscii(prop, str)) return true;
|
||||||
#define R(str) if (!set && 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
|
static bool
|
||||||
IsPermitted(const char *name, JSFlatString *prop, bool set)
|
IsPermitted(const char *name, JSFlatString *prop, bool set)
|
||||||
{
|
{
|
||||||
size_t propLength;
|
size_t propLength = JS_GetStringLength(JS_FORGET_STRING_FLATNESS(prop));
|
||||||
const jschar *propChars =
|
|
||||||
JS_GetInternedStringCharsAndLength(JS_FORGET_STRING_FLATNESS(prop), &propLength);
|
|
||||||
if (!propLength)
|
if (!propLength)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
jschar propChar0 = JS_GetFlatStringCharAt(prop, 0);
|
||||||
switch (name[0]) {
|
switch (name[0]) {
|
||||||
NAME('L', "Location",
|
NAME('L', "Location",
|
||||||
PROP('h', W("href"))
|
PROP('h', W("href"))
|
||||||
PROP('r', R("replace")))
|
PROP('r', R("replace")))
|
||||||
case 'W':
|
case 'W':
|
||||||
if (!strcmp(name, "Window"))
|
if (!strcmp(name, "Window"))
|
||||||
return dom::WindowBinding::IsPermitted(prop, propChars[0], set);
|
return dom::WindowBinding::IsPermitted(prop, propChar0, set);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -292,14 +292,15 @@ ExposedPropertiesOnly::check(JSContext *cx, JSObject *wrapperArg, jsid idArg, Wr
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSString *str = desc.value().toString();
|
JSFlatString *flat = JS_FlattenString(cx, desc.value().toString());
|
||||||
size_t length;
|
if (!flat)
|
||||||
const jschar *chars = JS_GetStringCharsAndLength(cx, str, &length);
|
|
||||||
if (!chars)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
size_t length = JS_GetStringLength(JS_FORGET_STRING_FLATNESS(flat));
|
||||||
|
|
||||||
for (size_t i = 0; i < length; ++i) {
|
for (size_t i = 0; i < length; ++i) {
|
||||||
switch (chars[i]) {
|
jschar ch = JS_GetFlatStringCharAt(flat, i);
|
||||||
|
switch (ch) {
|
||||||
case 'r':
|
case 'r':
|
||||||
if (access & READ) {
|
if (access & READ) {
|
||||||
EnterAndThrow(cx, wrapper, "duplicate 'readable' property flag");
|
EnterAndThrow(cx, wrapper, "duplicate 'readable' property flag");
|
||||||
|
|
Загрузка…
Ссылка в новой задаче