mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
JS: fix RegExp::getSuccessor/getPredecessor for sequence end/starts
This commit is contained in:
@@ -75,26 +75,41 @@ class RegExpTerm extends Locatable, @regexpterm {
|
||||
|
||||
/** Gets the regular expression term that is matched (textually) before this one, if any. */
|
||||
RegExpTerm getPredecessor() {
|
||||
exists(RegExpSequence seq, int i |
|
||||
seq.getChild(i) = this and
|
||||
seq.getChild(i - 1) = result
|
||||
exists(RegExpTerm parent | parent = getParent() |
|
||||
if parent instanceof RegExpSequence
|
||||
then
|
||||
exists(RegExpSequence seq, int i |
|
||||
seq = parent and
|
||||
seq.getChild(i) = this
|
||||
|
|
||||
seq.getChild(i - 1) = result
|
||||
or
|
||||
i = 0 and result = seq.getPredecessor()
|
||||
)
|
||||
else (
|
||||
not parent instanceof RegExpSubPattern and
|
||||
result = parent.getPredecessor()
|
||||
)
|
||||
)
|
||||
or
|
||||
result = getParent().(RegExpTerm).getPredecessor()
|
||||
}
|
||||
|
||||
/** Gets the regular expression term that is matched (textually) after this one, if any. */
|
||||
RegExpTerm getSuccessor() {
|
||||
exists(RegExpSequence seq, int i |
|
||||
seq.getChild(i) = this and
|
||||
seq.getChild(i + 1) = result
|
||||
)
|
||||
or
|
||||
exists(RegExpTerm parent |
|
||||
parent = getParent() and
|
||||
not parent instanceof RegExpSubPattern
|
||||
|
|
||||
result = parent.getSuccessor()
|
||||
exists(RegExpTerm parent | parent = getParent() |
|
||||
if parent instanceof RegExpSequence
|
||||
then
|
||||
exists(RegExpSequence seq, int i |
|
||||
seq = parent and
|
||||
seq.getChild(i) = this
|
||||
|
|
||||
seq.getChild(i + 1) = result
|
||||
or
|
||||
i = seq.getNumChild() - 1 and result = seq.getSuccessor()
|
||||
)
|
||||
else (
|
||||
not parent instanceof RegExpSubPattern and
|
||||
result = parent.getSuccessor()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
| tst.js:5:2:5:2 | a | tst.js:5:3:5:8 | (b[c]) |
|
||||
| tst.js:5:2:5:2 | a | tst.js:5:4:5:4 | b |
|
||||
| tst.js:5:2:5:2 | a | tst.js:5:4:5:7 | b[c] |
|
||||
| tst.js:5:2:5:2 | a | tst.js:5:5:5:7 | [c] |
|
||||
| tst.js:5:2:5:2 | a | tst.js:5:6:5:6 | c |
|
||||
| tst.js:5:4:5:4 | b | tst.js:5:5:5:7 | [c] |
|
||||
| tst.js:5:4:5:4 | b | tst.js:5:6:5:6 | c |
|
||||
| tst.js:6:2:6:2 | a | tst.js:6:3:6:9 | (b\|[b]) |
|
||||
@@ -20,8 +18,6 @@
|
||||
| tst.js:7:2:7:2 | a | tst.js:7:4:7:6 | [b] |
|
||||
| tst.js:7:2:7:2 | a | tst.js:7:4:7:9 | [b][c] |
|
||||
| tst.js:7:2:7:2 | a | tst.js:7:5:7:5 | b |
|
||||
| tst.js:7:2:7:2 | a | tst.js:7:7:7:9 | [c] |
|
||||
| tst.js:7:2:7:2 | a | tst.js:7:8:7:8 | c |
|
||||
| tst.js:7:4:7:6 | [b] | tst.js:7:7:7:9 | [c] |
|
||||
| tst.js:7:4:7:6 | [b] | tst.js:7:8:7:8 | c |
|
||||
| tst.js:8:2:8:2 | a | tst.js:8:3:8:13 | (b\|[b]\|[b]) |
|
||||
|
||||
@@ -16,17 +16,13 @@
|
||||
| tst.js:13:3:13:4 | ab | tst.js:13:6:13:6 | c |
|
||||
| tst.js:14:2:14:7 | ([a]b) | tst.js:14:8:14:8 | c |
|
||||
| tst.js:14:3:14:5 | [a] | tst.js:14:6:14:6 | b |
|
||||
| tst.js:14:3:14:5 | [a] | tst.js:14:8:14:8 | c |
|
||||
| tst.js:14:3:14:6 | [a]b | tst.js:14:8:14:8 | c |
|
||||
| tst.js:14:4:14:4 | a | tst.js:14:6:14:6 | b |
|
||||
| tst.js:14:4:14:4 | a | tst.js:14:8:14:8 | c |
|
||||
| tst.js:14:6:14:6 | b | tst.js:14:8:14:8 | c |
|
||||
| tst.js:16:2:16:9 | ([a][b]) | tst.js:16:10:16:10 | c |
|
||||
| tst.js:16:3:16:5 | [a] | tst.js:16:6:16:8 | [b] |
|
||||
| tst.js:16:3:16:5 | [a] | tst.js:16:10:16:10 | c |
|
||||
| tst.js:16:3:16:8 | [a][b] | tst.js:16:10:16:10 | c |
|
||||
| tst.js:16:4:16:4 | a | tst.js:16:6:16:8 | [b] |
|
||||
| tst.js:16:4:16:4 | a | tst.js:16:10:16:10 | c |
|
||||
| tst.js:16:6:16:8 | [b] | tst.js:16:10:16:10 | c |
|
||||
| tst.js:16:7:16:7 | b | tst.js:16:10:16:10 | c |
|
||||
| tst.js:17:2:17:12 | ([a]\|[a]\|a) | tst.js:17:13:17:13 | b |
|
||||
|
||||
Reference in New Issue
Block a user