Skip to content

avoid quadratic backtracking when parsing bracketed server names - #2489

Merged
manticore-projects merged 1 commit into
JSQLParser:masterfrom
dxbjavid:server-name-regex-backtracking
Aug 22, 2026
Merged

avoid quadratic backtracking when parsing bracketed server names#2489
manticore-projects merged 1 commit into
JSQLParser:masterfrom
dxbjavid:server-name-regex-backtracking

Conversation

@dxbjavid

Copy link
Copy Markdown
Contributor

Server's SERVER_PATTERN lets the first capturing group consume backslashes, so a bracketed name that is full of backslashes but never closes (for example [a\a\a...) makes the matcher explore every possible split between the server and instance groups, and the matching cost grows roughly quadratically with the length of the string, which can stall a thread that builds a Server from an untrusted qualified name. Excluding the backslash separator from the first group removes that ambiguity so matching stays linear, while [server\instance] and plain [server] still split exactly as before. The added test builds a Server from a long crafted value and would previously time out.

@manticore-projects
manticore-projects merged commit edd5bfc into JSQLParser:master Aug 22, 2026
7 checks passed
@dxbjavid

Copy link
Copy Markdown
Contributor Author

Thanks for the merge. Appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants