Skip to content

Commit 9a1c1f4

Browse files
committed
JS: Added in RegExpCreationNode maybeGlobal predicate for more convenience.
1 parent 1d2e08a commit 9a1c1f4

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

javascript/ql/lib/semmle/javascript/StandardLibrary.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@ class StringReplaceCall extends DataFlow::MethodCallNode {
121121
* Holds if this is a global replacement, that is, the first argument is a regular expression
122122
* with the `g` flag or unknown flags, or this is a call to `.replaceAll()`.
123123
*/
124-
predicate maybeGlobal() {
125-
RegExp::maybeGlobal(this.getRegExp().tryGetFlags()) or this.getMethodName() = "replaceAll"
126-
}
124+
predicate maybeGlobal() { this.getRegExp().maybeGlobal() or this.getMethodName() = "replaceAll" }
127125

128126
/**
129127
* Holds if this call to `replace` replaces `old` with `new`.

javascript/ql/lib/semmle/javascript/dataflow/Nodes.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,9 @@ class RegExpCreationNode extends DataFlow::SourceNode {
16851685
/** Holds if the constructed predicate has the `g` flag. */
16861686
predicate isGlobal() { RegExp::isGlobal(this.getFlags()) }
16871687

1688+
/** Holds if the constructed predicate has the `g` flag or unknown flags. */
1689+
predicate maybeGlobal() { RegExp::maybeGlobal(this.tryGetFlags()) }
1690+
16881691
/** Gets a data flow node referring to this regular expression. */
16891692
private DataFlow::SourceNode getAReference(DataFlow::TypeTracker t) {
16901693
t.start() and

0 commit comments

Comments
 (0)