Reject malformed version strings in ClickHouseVersion parser#1981
Open
il9ue wants to merge 4 commits into
Open
Reject malformed version strings in ClickHouseVersion parser#1981il9ue wants to merge 4 commits into
il9ue wants to merge 4 commits into
Conversation
The parser reads the version left to right. The moment it hit anything that wasn't a number (including a blank piece), it assumed "this must be the suffix" and quit reading the rest. Because of this, typos slipped through. In 26..1 the blank between the dots, the x in 26.x.1, and the empty piece after the dot in 26.1. all got mistaken for a suffix, so the parser accepted a broken version instead of complaining The fix: a piece only counts as the suffix if it's the very last piece and isn't blank. That rules out the three cases above Normal inputs are unaffected: short values like 25.3 (used in the compatibility setting) and real builds like 26.3.1.20001.altinityantalya still parse exactly as before Closes ClickHouse#1831
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.
The version parser stopped at the first non-numeric or empty token and treated the rest as the suffix, so
26..1,26.1.and26.x.1were accepted instead of rejected. A typo in thecompatibilitysetting could therefore apply the wrong profile silently.This restricts the suffix to a single non-empty trailing token, so malformed inputs throw BAD_ARGUMENTS again; valid versions and short forms like
25.3still parse. Adds a gtest for the parser.Closes #1831.
Changelog category (leave one):
CI/CD Options
Exclude tests:
Regression jobs to run: