JavaScript parser: fix some unterminated statement corner case issues
This fixes parsing of the following unterminated statements:
if () {
foo = 42
}
if () {
foo = new Object()
}
if () {
foo = ({a:1,b:2})
}
This commit is contained in:
parent
205bab83d7
commit
b9ca95c381
@ -1347,6 +1347,8 @@ static boolean parseStatement (tokenInfo *const token, boolean is_inside_class)
|
|||||||
makeJsTag (name, JSTAG_METHOD);
|
makeJsTag (name, JSTAG_METHOD);
|
||||||
parseBlock (token, name);
|
parseBlock (token, name);
|
||||||
}
|
}
|
||||||
|
else if (isType (token, TOKEN_CLOSE_CURLY))
|
||||||
|
is_terminated = FALSE;
|
||||||
}
|
}
|
||||||
else if (isType (token, TOKEN_OPEN_CURLY))
|
else if (isType (token, TOKEN_OPEN_CURLY))
|
||||||
{
|
{
|
||||||
@ -1441,6 +1443,8 @@ static boolean parseStatement (tokenInfo *const token, boolean is_inside_class)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (isType (token, TOKEN_CLOSE_CURLY))
|
||||||
|
is_terminated = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isKeyword (token, KEYWORD_NONE))
|
else if (isKeyword (token, KEYWORD_NONE))
|
||||||
@ -1486,23 +1490,29 @@ static boolean parseStatement (tokenInfo *const token, boolean is_inside_class)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
findCmdTerm (token);
|
|
||||||
|
|
||||||
/*
|
/* if we aren't already at the cmd end, advance to it and check whether
|
||||||
* Statements can be optionally terminated in the case of
|
* the statement was terminated */
|
||||||
* statement prior to a close curly brace as in the
|
if (! isType (token, TOKEN_CLOSE_CURLY) &&
|
||||||
* document.write line below:
|
! isType (token, TOKEN_SEMICOLON))
|
||||||
*
|
{
|
||||||
* function checkForUpdate() {
|
findCmdTerm (token);
|
||||||
* if( 1==1 ) {
|
|
||||||
* document.write("hello from checkForUpdate<br>")
|
|
||||||
* }
|
|
||||||
* return 1;
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
if ( ! is_terminated && isType (token, TOKEN_CLOSE_CURLY))
|
|
||||||
is_terminated = FALSE;
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Statements can be optionally terminated in the case of
|
||||||
|
* statement prior to a close curly brace as in the
|
||||||
|
* document.write line below:
|
||||||
|
*
|
||||||
|
* function checkForUpdate() {
|
||||||
|
* if( 1==1 ) {
|
||||||
|
* document.write("hello from checkForUpdate<br>")
|
||||||
|
* }
|
||||||
|
* return 1;
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
if (isType (token, TOKEN_CLOSE_CURLY))
|
||||||
|
is_terminated = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
cleanUp:
|
cleanUp:
|
||||||
vStringCopy(token->scope, saveScope);
|
vStringCopy(token->scope, saveScope);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user