fix(Foundation): Reject trailing garbage in DateTimeParser (#5030)#5117
Merged
fix(Foundation): Reject trailing garbage in DateTimeParser (#5030)#5117
Conversation
Contributor
Author
Test Fix DetailsThe test failures ( Root CauseThe tests created tables with When extracting from a
FixChanged column type from
This ensures the column type matches what's being stored. The DateTimeParser fix exposed a pre-existing schema bug in the tests. |
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.
Summary
Fixes #5030 - DateTimeParser now properly rejects input strings with unconsumed trailing characters.
Problem
DateTimeParser::parse()andtryParse()were accepting invalid input strings that didn't match the format:Solution
After consuming all format specifiers, the parser now:
SyntaxExceptionif any non-whitespace characters remainThe fix maintains backwards compatibility by keeping the lenient literal character matching (format literals that don't match input are skipped), which existing code relies on.
Changes
DateTimeParser.cpp: Added trailing garbage detection after parsing loopDateTimeParserTest.cpp: Added test cases from issue Foundation: DateTimeParser accepts trailing garbage #5030Test Results
All existing tests pass, plus the new issue-specific tests:
"%H:%M"with"13:13"→ success ✓"%H:%M"with"xxx"→ failure ✓"%H:%M"with"12345"→ failure (trailing garbage) ✓"????"with"12345"→ failure (invalid format) ✓