🐛 Fix decoder bug when option value encoding does not end with a control character #2721
+58
−20
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.
WHY are these changes introduced?
The decoder did not correctly handle the case of an encoding ending with an index, and either no previous control chars OR a
char.
Examples:
V1_0
incorrectly decoded to[]
instead of[[0]]
V1_0 5
incorrectly decoded to[[0]]
instead of[[0], [5]]
WHAT is this pull request doing?
The root of the problem is that the decoder processes tokens and then does a look-back to grab the index to process. If the final char of the encoding is not a control char, it never looks back. We previously handled this with an exception for the range case but missed the case where a range char is not present.
This PR adds a more generic handler for encodings that end with an index.
Q: The exception handler only accounts for no control char, a
. Don't we need to handle
-
or a:
and,
too?A: No. If an encoded string contains a
:
or a,
anywhere, the string will always end with a,
.HOW to test your changes?
Do tests pass?
Post-merge steps
Checklist