Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f726125

Browse files
author
Max Schaefer
committed
JavaScript: Restrict E4X processing instruction disambiguation to the <?xml ...?> case.
1 parent 5a775d9 commit f726125

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

javascript/extractor/src/com/semmle/jcorn/CustomParser.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,13 @@ protected Token readToken(int code) {
551551
// chunk of E4X content and a Flow type annotation (both can start with `<?`)
552552
// hence if we can't find the closing `?>` of a putative XML processing instruction
553553
// we backtrack and try lexing as something else
554+
// to avoid frequent backtracking, we only consider `<?xml ...?>` processing instructions;
555+
// while other processing instructions are technically possible, they are unlikely in practice
554556
if (this.options.e4x()) {
555557
while (code == '<') {
556-
if (charAt(this.pos+1) == '?') {
558+
if (inputSubstring(this.pos+1, this.pos+5).equals("?xml")) {
557559
int oldPos = this.pos;
558-
this.pos += 2;
560+
this.pos += 5;
559561
if (!jsx_readUntil("?>")) {
560562
// didn't find a closing `?>`, so backtrack
561563
this.pos = oldPos;

0 commit comments

Comments
 (0)