Force XML option on inside a literal list or element, to allow comments and CDATA (311157, r/sr=mrbkap/shaver, a=asa).
git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@181970 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -3660,6 +3660,25 @@ XMLElementOrList(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
||||
return pn;
|
||||
}
|
||||
|
||||
static JSParseNode *
|
||||
XMLElementOrListRoot(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
||||
JSBool allowList)
|
||||
{
|
||||
uint32 oldopts;
|
||||
JSParseNode *pn;
|
||||
|
||||
/*
|
||||
* Force XML support to be enabled so that comments and CDATA literals
|
||||
* are recognized, instead of <! followed by -- starting an HTML comment
|
||||
* to end of line (used in script tags to hide content from old browsers
|
||||
* that don't recognize <script>).
|
||||
*/
|
||||
oldopts = JS_SetOptions(cx, cx->options | JSOPTION_XML);
|
||||
pn = XMLElementOrList(cx, ts, tc, allowList);
|
||||
JS_SetOptions(cx, oldopts);
|
||||
return pn;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSParseNode *)
|
||||
js_ParseXMLTokenStream(JSContext *cx, JSObject *chain, JSTokenStream *ts,
|
||||
JSBool allowList)
|
||||
@@ -3701,7 +3720,7 @@ js_ParseXMLTokenStream(JSContext *cx, JSObject *chain, JSTokenStream *ts,
|
||||
JSMSG_BAD_XML_MARKUP);
|
||||
pn = NULL;
|
||||
} else {
|
||||
pn = XMLElementOrList(cx, ts, &tc, allowList);
|
||||
pn = XMLElementOrListRoot(cx, ts, &tc, allowList);
|
||||
}
|
||||
|
||||
ts->flags &= ~TSF_XMLONLYMODE;
|
||||
@@ -3990,7 +4009,7 @@ PrimaryExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
|
||||
break;
|
||||
|
||||
case TOK_XMLSTAGO:
|
||||
pn = XMLElementOrList(cx, ts, tc, JS_TRUE);
|
||||
pn = XMLElementOrListRoot(cx, ts, tc, JS_TRUE);
|
||||
if (!pn)
|
||||
return NULL;
|
||||
notsharp = JS_TRUE; /* XXXbe could be sharp? */
|
||||
|
||||
@@ -1892,7 +1892,6 @@ ParseXMLSource(JSContext *cx, JSString *src)
|
||||
uintN lineno;
|
||||
JSStackFrame *fp;
|
||||
JSOp op;
|
||||
uint32 oldopts;
|
||||
JSParseNode *pn;
|
||||
JSXML *xml;
|
||||
JSXMLArray nsarray;
|
||||
@@ -1946,8 +1945,6 @@ ParseXMLSource(JSContext *cx, JSString *src)
|
||||
}
|
||||
}
|
||||
|
||||
/* Toggle on XML support since the script has explicitly requested it. */
|
||||
oldopts = JS_SetOptions(cx, cx->options | JSOPTION_XML);
|
||||
JS_KEEP_ATOMS(cx->runtime);
|
||||
pn = js_ParseXMLTokenStream(cx, cx->fp->scopeChain, ts, JS_FALSE);
|
||||
xml = NULL;
|
||||
@@ -1958,7 +1955,6 @@ ParseXMLSource(JSContext *cx, JSString *src)
|
||||
XMLArrayFinish(cx, &nsarray);
|
||||
}
|
||||
JS_UNKEEP_ATOMS(cx->runtime);
|
||||
JS_SetOptions(cx, oldopts);
|
||||
|
||||
JS_ARENA_RELEASE(&cx->tempPool, mark);
|
||||
JS_free(cx, chars);
|
||||
|
||||
Reference in New Issue
Block a user