Re: Feature request: more robust handling of invalid UTF-16 data
Maks Verver <[email protected]> Sun, 16 Feb 2020 21:20:44 +0100
| Newsgroups | gmane.comp.db.sqlite.general |
|---|---|
| Message-ID | <CANOrs7HgZCNSkuLhQfgAHRfVVWCoBH-vGq-qQ7E5N2OLxV9REA@mail.gmail.com> |
*Richard:* the issue with the JSON extension seems unrelated to the issue
that I reported originally, which relates to the SQLite C API
(specifically, the sqlite3_bind_text16() and sqlite3_bind_text16()
functions). My issue is still not fixed.
I've expanded my original sample code to make it easier to run the test and
reproduce the problems:
https://gist.github.com/maksverver/c3d5da8a0a9f2ec1c2a225209f290e13
Let me know if you need more help understanding/reproducing the problem.
*Dennis:* thanks for raising the issue again, and for digging through the
Unicode standard to confirm the most reasonable behavior.
I think your proposed patch is not quite correct. I think I spot two
problems. One:
if( c>=0xDC00 && c<=0xE000 && TERM ) {
.. here, you should drop the `&& TERM`, otherwise you'll fail to replace a
high surrogate when it occurs at the end of the string. Also, you should
check c<0xE000 because 0xE000 is a valid character by itself. Two:
} else if( c>=0xD800 && TERM ){
Here, you should also check c<0xDC00 (or c<0xE000), otherwise you'll
misinterpret valid characters with code points 0xE000 and above as part of
a surrogate pair.
I believe my original patch handles these and all other cases correctly.
- Maks.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users