Skip to content

Commit 1bb6f49

Browse files
committed
C#: Match any {digit} in the format string.
1 parent b006b28 commit 1bb6f49

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

csharp/ql/lib/semmle/code/csharp/security/dataflow/UrlRedirectQuery.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,12 @@ private class InterpolationSanitizer extends Sanitizer {
184184
*/
185185
private class StringFormatSanitizer extends Sanitizer {
186186
StringFormatSanitizer() {
187-
exists(FormatCall c, Expr e | c = this.getExpr() and e = c.getFormatExpr() |
188-
e.(StringLiteral).getValue().splitAt("{0}", 0).matches("%?%")
187+
exists(FormatCall c, Expr e, int index, string format |
188+
c = this.getExpr() and e = c.getFormatExpr()
189+
|
190+
format = e.(StringLiteral).getValue() and
191+
exists(format.regexpFind("\\{[0-9]+\\}", 0, index)) and
192+
format.substring(0, index).matches("%?%")
189193
)
190194
}
191195
}

0 commit comments

Comments
 (0)