Fix DurationParser allowing invalid input#772
Fix DurationParser allowing invalid input#772emilyy-dev wants to merge 6 commits intoIncendo:masterfrom
DurationParser allowing invalid input#772Conversation
…nually parsing the input
Test Results 88 files ±0 88 suites ±0 11s ⏱️ -1s Results for commit 325d896. ± Comparison against base commit 66a0143. This pull request removes 1 and adds 6 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
This isn't the case in 2.x, the tree will restore the cursor on a failed parse. You only need to do this if your parsing logic calls for it. |
In that case the docs need updating 👍🏻 I'll revert that change here for now |
Yes, the docs should be updated. When we switched over to the |
DurationParserusing that regex andMatcher#find()only finds the pattern in the given input string, while the pattern is right for individual segments denoting value-unit sequences, it does not prevent the input to have non-matching content.This patch fixes that by manually parsing the input.
Additionally it conforms to the recommended way of parsing an argument: peek input, pop input on successful parsing.