From b98293e405eda13a67cae6da654d9774c90f3650 Mon Sep 17 00:00:00 2001 From: Akihiro Sagawa Date: Mon, 10 Oct 2016 22:53:15 +0900 Subject: [PATCH] webservices: Add support for decoding supplementary characters' references. Signed-off-by: Akihiro Sagawa Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/webservices/reader.c | 3 ++- dlls/webservices/tests/reader.c | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c index de926033369..a6f5d6bc94b 100644 --- a/dlls/webservices/reader.c +++ b/dlls/webservices/reader.c @@ -1190,6 +1190,7 @@ static int codepoint_to_utf8( int cp, unsigned char *dst ) dst[0] = 0xe0 | cp; return 3; } + if (cp >= 0x110000) return -1; dst[3] = 0x80 | (cp & 0x3f); cp >>= 6; dst[2] = 0x80 | (cp & 0x3f); @@ -1259,7 +1260,7 @@ static HRESULT decode_text( const unsigned char *str, ULONG len, unsigned char * if (!len) return WS_E_INVALID_FORMAT; p -= nb_digits = start - len; - if (!nb_digits || nb_digits > 5 || p[nb_digits] != ';') return WS_E_INVALID_FORMAT; + if (!nb_digits || nb_digits > 6 || p[nb_digits] != ';') return WS_E_INVALID_FORMAT; for (i = 0; i < nb_digits; i++) { cp *= 16; diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c index f0fe729c643..a020c0111ef 100644 --- a/dlls/webservices/tests/reader.c +++ b/dlls/webservices/tests/reader.c @@ -3614,11 +3614,16 @@ static void test_entities(void) static const char str29[] = ""; static const char str30[] = "A"; static const char str31[] = ""; + static const char str32[] = "􏿿"; + static const char str33[] = ""; + static const char str34[] = "􏿿"; + static const char str35[] = ""; static const char res4[] = {0xea, 0xaa, 0xaa, 0x00}; static const char res5[] = {0xf2, 0xaa, 0xaa, 0xaa, 0x00}; static const char res21[] = {0xed, 0x9f, 0xbf, 0x00}; static const char res24[] = {0xee, 0x80, 0x80, 0x00}; static const char res31[] = {0xef, 0xbd, 0xb1, 0x00}; + static const char res32[] = {0xf4, 0x8f, 0xbf, 0xbf, 0x00}; static const struct { const char *str; @@ -3658,6 +3663,10 @@ static void test_entities(void) { str29, WS_E_INVALID_FORMAT }, { str30, S_OK, "A" }, { str31, S_OK, res31 }, + { str32, S_OK, res32 }, + { str33, WS_E_INVALID_FORMAT }, + { str34, S_OK, res32 }, + { str35, WS_E_INVALID_FORMAT }, }; HRESULT hr; WS_XML_READER *reader; -- 2.11.4.GIT