Commit 529cbc7
committed
init: fix unescape_string not advancing past escape characters
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 a spurious
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 '&&'.1 parent 391409d commit 529cbc7
1 file changed
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
666 | 666 | | |
667 | 667 | | |
668 | 668 | | |
669 | | - | |
| 669 | + | |
| 670 | + | |
670 | 671 | | |
671 | 672 | | |
672 | 673 | | |
| |||
692 | 693 | | |
693 | 694 | | |
694 | 695 | | |
| 696 | + | |
695 | 697 | | |
696 | 698 | | |
697 | 699 | | |
| 700 | + | |
698 | 701 | | |
699 | 702 | | |
700 | 703 | | |
| |||
0 commit comments