Skip to content

Commit

Permalink
JS: In oprder to keep code more consistent removed predicate isGlobal…
Browse files Browse the repository at this point in the history
… from RegExpCreationNode and reused RegExp::isGlobal in std
  • Loading branch information
Napalys committed Nov 25, 2024
1 parent d6372ae commit b39a8fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 3 additions & 1 deletion javascript/ql/lib/semmle/javascript/StandardLibrary.qll
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ class StringReplaceCall extends DataFlow::MethodCallNode {
* Holds if this is a global replacement, that is, the first argument is a regular expression
* with the `g` flag, or this is a call to `.replaceAll()`.
*/
predicate isGlobal() { this.getRegExp().isGlobal() or this.getMethodName() = "replaceAll" }
predicate isGlobal() {
RegExp::isGlobal(this.getRegExp().getFlags()) or this.getMethodName() = "replaceAll"
}

/**
* Holds if this call to `replace` replaces `old` with `new`.
Expand Down
3 changes: 0 additions & 3 deletions javascript/ql/lib/semmle/javascript/dataflow/Nodes.qll
Original file line number Diff line number Diff line change
Expand Up @@ -1682,9 +1682,6 @@ class RegExpCreationNode extends DataFlow::SourceNode {
result = this.(RegExpLiteralNode).getFlags()
}

/** Holds if the constructed predicate has the `g` flag. */
predicate isGlobal() { RegExp::isGlobal(this.getFlags()) }

/** Gets a data flow node referring to this regular expression. */
private DataFlow::SourceNode getAReference(DataFlow::TypeTracker t) {
t.start() and
Expand Down

0 comments on commit b39a8fe

Please sign in to comment.