diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-04-07 07:09:15 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-04-07 07:09:15 -0700 |
commit | e2fe814938e7e8aa9286e9ba3e1c0fd7eff37766 (patch) | |
tree | 237189e4bef17a403f81e38703566e274846a8c6 /tl.vim | |
parent | 38b710b262d96a004092b618f508b2e97f5b2977 (diff) | |
download | txr-e2fe814938e7e8aa9286e9ba3e1c0fd7eff37766.tar.gz txr-e2fe814938e7e8aa9286e9ba3e1c0fd7eff37766.tar.bz2 txr-e2fe814938e7e8aa9286e9ba3e1c0fd7eff37766.zip |
utf8: fix backtracking bugs in buffer decoder.
* utf8.c (utf8_from_buffer): Fix incorrect backtracking logic
for handling bad UTF-8 bytes. Firstly, we are not backtracking
to the correct byte. Because src is incremented at the top of
the loop, the backtrack pointer must be set to src - 1 to
point to the possibly bad byte. Secondly, when we backtrack,
we are neglecting to rewinding nbytes! Thus after
backtracking, we will not scan the entire input. Let's avoid
using nbytes, and guard the loop based on whether we hit the
end of the buffer; then we don't have any nbytes state to
backtrack.
* tests/017/ffi-misc.tl: New test case converting a three-byte
UTF-8 encoding of U+DC01: an invalid character in the
surrogate range. We test that the buffer decoder turns this
into three characters, exactly like the stream decoder.
Another test case for invalid bytes following a valid
sequence start.
Diffstat (limited to 'tl.vim')
0 files changed, 0 insertions, 0 deletions