Repository navigation
avoid quadratic quote stripping in MultiPartName.unquote - #2858
Merged
manticore-projects merged 1 commit intoOct 25, 2026
Merged
manticore-projects merged 1 commit into
manticore-projects merged 1 commit into
Conversation
Contributor
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MultiPartName.unquote strips identifier quotes with
^["\[]+|["]]+$, and Table.setName and Column.setName call it whenever a name contains a dot, so it runs on identifiers straight out of CCJSqlParserUtil.parse. The trailing alternative has no left anchor, so replaceAll retries it at every offset inside a run of quote characters, and each attempt consumes the rest of the run before failing on$. A quoted identifier can legally hold any number of doubled""escapes, which makes that run as long as the caller wants: parsingSELECT * FROM "a""""...""".b"takes 440 ms with 10k quotes, 3.9 s with 20k, and hits the parser timeout at 40k, while the same statements parse in under 10 ms with this change. I found it while looking for other regexes applied to token images after the earlier hint and server-name fixes. unquote and isQuoted now scan the leading and trailing quote characters directly, with the same character sets and the same leading-then-trailing order, so results do not change; LEADING_TRAILING_QUOTES_PATTERN stays because it is a public constant. The new tests compare both methods against the old pattern on a set of edge cases and parse the crafted statement under a 2 second preemptive timeout.