Commit dd4c126e authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

webservices: Add support for decoding decimal numeric character references.

parent 064edd2d
...@@ -1249,7 +1249,9 @@ static HRESULT decode_text( const unsigned char *str, ULONG len, unsigned char * ...@@ -1249,7 +1249,9 @@ static HRESULT decode_text( const unsigned char *str, ULONG len, unsigned char *
int len_utf8, cp = 0; int len_utf8, cp = 0;
p++; len--; p++; len--;
if (!len || *p != 'x') return WS_E_INVALID_FORMAT; if (!len) return WS_E_INVALID_FORMAT;
else if (*p == 'x')
{
p++; len--; p++; len--;
start = len; start = len;
...@@ -1266,6 +1268,26 @@ static HRESULT decode_text( const unsigned char *str, ULONG len, unsigned char * ...@@ -1266,6 +1268,26 @@ static HRESULT decode_text( const unsigned char *str, ULONG len, unsigned char *
else cp += *p - 'A' + 10; else cp += *p - 'A' + 10;
p++; 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--; p++; len--;
if ((len_utf8 = codepoint_to_utf8( cp, q )) < 0) return WS_E_INVALID_FORMAT; if ((len_utf8 = codepoint_to_utf8( cp, q )) < 0) return WS_E_INVALID_FORMAT;
*ret_len += len_utf8; *ret_len += len_utf8;
......
...@@ -3611,10 +3611,14 @@ static void test_entities(void) ...@@ -3611,10 +3611,14 @@ static void test_entities(void)
static const char str26[] = "<t>&#xffff;</t>"; static const char str26[] = "<t>&#xffff;</t>";
static const char str27[] = "<t>&LT;</t>"; static const char str27[] = "<t>&LT;</t>";
static const char str28[] = "<t>&#x0;</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 res4[] = {0xea, 0xaa, 0xaa, 0x00};
static const char res5[] = {0xf2, 0xaa, 0xaa, 0xaa, 0x00}; static const char res5[] = {0xf2, 0xaa, 0xaa, 0xaa, 0x00};
static const char res21[] = {0xed, 0x9f, 0xbf, 0x00}; static const char res21[] = {0xed, 0x9f, 0xbf, 0x00};
static const char res24[] = {0xee, 0x80, 0x80, 0x00}; static const char res24[] = {0xee, 0x80, 0x80, 0x00};
static const char res31[] = {0xef, 0xbd, 0xb1, 0x00};
static const struct static const struct
{ {
const char *str; const char *str;
...@@ -3651,6 +3655,9 @@ static void test_entities(void) ...@@ -3651,6 +3655,9 @@ static void test_entities(void)
{ str26, WS_E_INVALID_FORMAT }, { str26, WS_E_INVALID_FORMAT },
{ str27, WS_E_INVALID_FORMAT }, { str27, WS_E_INVALID_FORMAT },
{ str28, WS_E_INVALID_FORMAT }, { str28, WS_E_INVALID_FORMAT },
{ str29, WS_E_INVALID_FORMAT },
{ str30, S_OK, "A" },
{ str31, S_OK, res31 },
}; };
HRESULT hr; HRESULT hr;
WS_XML_READER *reader; WS_XML_READER *reader;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment