Skip to content

Commit c59d3f1

Browse files
committed
JavaScript: (bugfix) consider << operator when detecting JSX area
Fixed #4227. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
1 parent fccad9b commit c59d3f1

File tree

6 files changed

+27
-0
lines changed

6 files changed

+27
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a crash test.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--input-encoding=UTF-8
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"\uFEFF"<<={
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"\uFEFF"<={
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"\uFEFF"<<{

parsers/jscript.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,29 @@ static void readTokenFullRaw (tokenInfo *const token, bool include_newlines, vSt
12031203

12041204
case '<':
12051205
if (doesExpectBinaryOperator (LastTokenType))
1206+
{
12061207
token->type = TOKEN_BINARY_OPERATOR;
1208+
/*
1209+
* Skip '<<', '<<=', and '<='.
1210+
*
1211+
* '<<' must be handled here.
1212+
* If '<<' is read as two tokens, '<'
1213+
* and '<', the parser treats the second one
1214+
* as the start of JSX_TOKEN.
1215+
*
1216+
* Handling '<=' and '<<=' here is just for minor
1217+
* optimization.
1218+
*/
1219+
int d = getcFromInputFile ();
1220+
if (d == '<')
1221+
{
1222+
d = getcFromInputFile ();
1223+
if (d != '=')
1224+
ungetcToInputFile (d);
1225+
}
1226+
else if (d != '=')
1227+
ungetcToInputFile (d);
1228+
}
12071229
else
12081230
{
12091231
bool skip = !isXtagEnabled (XTAG_GUEST);

0 commit comments

Comments
 (0)