Skip to content

Commit 83f5b61

Browse files
author
Max Schaefer
committed
JavaScript: Switch detection of callback-based string replacement to data flow.
1 parent 1951461 commit 83f5b61

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

javascript/ql/src/semmle/javascript/StandardLibrary.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ class StringReplaceCall extends DataFlow::MethodCallNode {
281281
}
282282

283283
/**
284-
* Holds if this is a global replacement, that is, the first argument is a regulare expression
284+
* Holds if this is a global replacement, that is, the first argument is a regular expression
285285
* with the `g` flag.
286286
*/
287287
predicate isGlobal() {
@@ -303,7 +303,7 @@ class StringReplaceCall extends DataFlow::MethodCallNode {
303303
replacer.getParameter(0).flowsToExpr(pr.getPropertyNameExpr()) and
304304
pr = map.getAPropertyRead() and
305305
pr.flowsTo(replacer.getAReturn()) and
306-
map.asExpr().(ObjectExpr).getPropertyByName(old).getInit().getStringValue() = new
306+
map.hasPropertyWrite(old, any(DataFlow::Node repl | repl.getStringValue() = new))
307307
)
308308
}
309309
}

0 commit comments

Comments
 (0)