init: fix unescape_string not advancing past escape characters#669
Draft
nikromen wants to merge 1 commit intocontainers:mainfrom
Draft
init: fix unescape_string not advancing past escape characters#669nikromen wants to merge 1 commit intocontainers:mainfrom
nikromen wants to merge 1 commit intocontainers:mainfrom
Conversation
606aab5 to
529cbc7
Compare
After processing a \X escape sequence in the switch block, the read
pointer (val) was not advanced past the matched character. The next
loop iteration re-processed it as a literal, producing an
extra byte for every escape sequence.
For example, JSON "\n" decoded to {0x0A, 'n'} instead of {0x0A},
and JSON "\\\\" decoded to {'\', <next char interpreted as escape>}
instead of {'\'}.
Also fix the \u case: hexToDigit was called with a pointer to 'u'
instead of the first hex digit (val++ vs ++val), and the write index
was not advanced after memcpy, so decoded Unicode characters were
silently dropped. This caused e.g. \u0026 ('&') to be lost, breaking
any container command containing '&&'.
529cbc7 to
b6a5283
Compare
Author
|
hmmm, both this and #668 are still not working as I thought :/ will look at it later 😴 |
Member
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.
After processing a \X escape sequence in the switch block, the read
pointer (val) was not advanced past the matched character. The next
loop iteration re-processed it as a literal, producing an
extra byte for every escape sequence.
For example, JSON "\n" decoded to {0x0A, 'n'} instead of {0x0A},
and JSON "\\" decoded to {'', }
instead of {''}.
Also fix the \u case: hexToDigit was called with a pointer to 'u'
instead of the first hex digit (val++ vs ++val), and the write index
was not advanced after memcpy, so decoded Unicode characters were
silently dropped. This caused e.g. \u0026 ('&') to be lost, breaking
any container command containing '&&'.
Reproducer (on fedora 43 x86):
Expected output is:
and second & bug:
expected outoput: