webservices: Add support for decoding decimal numeric character references.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2016-10-10 22:53:14 +09:00 committed by Alexandre Julliard
parent 064edd2d8b
commit dd4c126e95
2 changed files with 43 additions and 14 deletions

View File

@ -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')
{
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++;
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 ))
{
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;

View File

@ -3611,10 +3611,14 @@ static void test_entities(void)
static const char str26[] = "<t>&#xffff;</t>";
static const char str27[] = "<t>&LT;</t>";
static const char str28[] = "<t>&#x0;</t>";
static const char str29[] = "<t>&#0;</t>";
static const char str30[] = "<t>&#65;</t>";
static const char str31[] = "<t>&#65393;</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;