diff options
author | Brad King <brad.king@kitware.com> | 2019-03-18 15:28:43 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-03-18 15:28:52 (GMT) |
commit | 875f49cc588b898f5da24bff34638d16de5c6413 (patch) | |
tree | 67d6b95887ac9cd125af2273e34718d6ef05230d /Source/cm_utf8.c | |
parent | f6cbb02b59d179c572c347461e81201bdd2337ed (diff) | |
parent | fb5de060bc99635a5b18b3389cc15e9937b19a0e (diff) | |
download | CMake-875f49cc588b898f5da24bff34638d16de5c6413.zip CMake-875f49cc588b898f5da24bff34638d16de5c6413.tar.gz CMake-875f49cc588b898f5da24bff34638d16de5c6413.tar.bz2 |
Merge topic 'utf8-fixes'
fb5de060bc cm_utf8: reject codepoints above 0x10FFFF
a11e5e021b cm_utf8: reject UTF-16 surrogate half codepoints
7111873efd testUTF8: add more test cases
bba2b1c89b testUTF8: comment why sequences are invalid
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3097
Diffstat (limited to 'Source/cm_utf8.c')
-rw-r--r-- | Source/cm_utf8.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Source/cm_utf8.c b/Source/cm_utf8.c index 52af4a6..d41d097 100644 --- a/Source/cm_utf8.c +++ b/Source/cm_utf8.c @@ -71,6 +71,16 @@ const char* cm_utf8_decode_character(const char* first, const char* last, return 0; } + /* UTF-16 surrogate halves. */ + if (0xD800 <= uc && uc <= 0xDFFF) { + return 0; + } + + /* Invalid codepoints. */ + if (0x10FFFF < uc) { + return 0; + } + *pc = uc; return first; } |