Skip to content

Commit 0c7fd10

Browse files
committed
switch to a more accurate regular expression that avoids stack overflow
1 parent b5c215d commit 0c7fd10

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

instrumentation-api-incubator/src/main/jflex/SqlSanitizer.jflex

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ WHITESPACE = [ \t\r\n]+
5454
// max length of the sanitized statement - SQLs longer than this will be trimmed
5555
static final int LIMIT = 32 * 1024;
5656

57-
// Match on "IN(?, ?, ...)". This can also match invalid sql syntax like IN(?,,), which is a tradeoff to avoid stack overflows
58-
private static final Pattern IN_STATEMENT_PATTERN = Pattern.compile("\\sin\\s*\\(\\s*\\?[\\s?,]*?\\)", Pattern.CASE_INSENSITIVE);
57+
// Match on "IN(?, ?, ...)"
58+
private static final Pattern IN_STATEMENT_PATTERN = Pattern.compile("(\\sin\\s*)\\(\\s*\\?\\s*(,\\s*\\?\\s*)*+\\)", Pattern.CASE_INSENSITIVE);
5959
private static final String IN_STATEMENT_NORMALIZED = " in(?)";
6060

6161
private final StringBuilder builder = new StringBuilder();

0 commit comments

Comments
 (0)