Akihiro Sagawa : webservices: Add support for decoding decimal numeric character references.
Alexandre Julliard
julliard at winehq.org
Mon Oct 10 15:09:44 CDT 2016
Module: wine
Branch: master
Commit: dd4c126e956281269dca5a9025159dd1c802ed27
URL: http://source.winehq.org/git/wine.git/?a=commit;h=dd4c126e956281269dca5a9025159dd1c802ed27
Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date: Mon Oct 10 22:53:14 2016 +0900
webservices: Add support for decoding decimal numeric character references.
Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/webservices/reader.c | 50 +++++++++++++++++++++++++++++------------
dlls/webservices/tests/reader.c | 7 ++++++
2 files changed, 43 insertions(+), 14 deletions(-)
diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c
index 655288a..de92603 100644
--- a/dlls/webservices/reader.c
+++ b/dlls/webservices/reader.c
@@ -1249,23 +1249,45 @@ static HRESULT decode_text( const unsigned char *str, ULONG len, unsigned char *
int len_utf8, cp = 0;
p++; len--;
- if (!len || *p != 'x') return WS_E_INVALID_FORMAT;
- p++; len--;
-
- start = len;
- while (len && isxdigit( *p )) { p++; len--; };
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;
- for (i = 0; i < nb_digits; i++)
+ else if (*p == 'x')
+ {
+ p++; len--;
+
+ start = len;
+ while (len && isxdigit( *p )) { p++; len--; };
+ 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;
+ for (i = 0; i < nb_digits; i++)
+ {
+ cp *= 16;
+ if (*p >= '0' && *p <= '9') cp += *p - '0';
+ else if (*p >= 'a' && *p <= 'f') cp += *p - 'a' + 10;
+ else cp += *p - 'A' + 10;
+ p++;
+ }
+ }
+ else if (isdigit( *p ))
{
- cp *= 16;
- if (*p >= '0' && *p <= '9') cp += *p - '0';
- else if (*p >= 'a' && *p <= 'f') cp += *p - 'a' + 10;
- else cp += *p - 'A' + 10;
- p++;
+ while (len && *p == '0') { p++; len--; };
+ if (!len) return WS_E_INVALID_FORMAT;
+
+ start = len;
+ while (len && isdigit( *p )) { p++; len--; };
+ if (!len) return WS_E_INVALID_FORMAT;
+
+ p -= nb_digits = start - len;
+ if (!nb_digits || nb_digits > 7 || p[nb_digits] != ';') return WS_E_INVALID_FORMAT;
+ for (i = 0; i < nb_digits; i++)
+ {
+ cp *= 10;
+ cp += *p - '0';
+ p++;
+ }
}
+ else return WS_E_INVALID_FORMAT;
p++; len--;
if ((len_utf8 = codepoint_to_utf8( cp, q )) < 0) return WS_E_INVALID_FORMAT;
*ret_len += len_utf8;
diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c
index 76de14a..f0fe729 100644
--- a/dlls/webservices/tests/reader.c
+++ b/dlls/webservices/tests/reader.c
@@ -3611,10 +3611,14 @@ static void test_entities(void)
static const char str26[] = "<t></t>";
static const char str27[] = "<t><</t>";
static const char str28[] = "<t>�</t>";
+ static const char str29[] = "<t></t>";
+ static const char str30[] = "<t>A</t>";
+ static const char str31[] = "<t>ア</t>";
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 struct
{
const char *str;
@@ -3651,6 +3655,9 @@ static void test_entities(void)
{ str26, WS_E_INVALID_FORMAT },
{ str27, WS_E_INVALID_FORMAT },
{ str28, WS_E_INVALID_FORMAT },
+ { str29, WS_E_INVALID_FORMAT },
+ { str30, S_OK, "A" },
+ { str31, S_OK, res31 },
};
HRESULT hr;
WS_XML_READER *reader;
More information about the wine-cvs
mailing list