xmllite: Partially implement value normalization for CDATA sections.

This commit is contained in:
Nikolay Sivov 2013-03-24 00:04:12 +04:00 committed by Alexandre Julliard
parent 448e939ebe
commit 2bdaffd879
2 changed files with 23 additions and 2 deletions

View file

@ -1835,6 +1835,12 @@ static HRESULT reader_parse_cdata(xmlreader *reader)
}
else
{
/* Value normalization is not fully implemented, rules are:
- single '\r' -> '\n';
- sequence '\r\n' -> '\n', in this case value length changes;
*/
if (*ptr == '\r') *ptr = '\n';
reader_skipn(reader, 1);
ptr++;
}

View file

@ -771,6 +771,7 @@ struct test_entry {
const char *value;
HRESULT hr;
HRESULT hr_broken; /* this is set to older version results */
int todo : 1;
};
static struct test_entry comment_tests[] = {
@ -1317,6 +1318,9 @@ static void test_readvaluechunk(void)
static struct test_entry cdata_tests[] = {
{ "<a><![CDATA[ ]]data ]]></a>", "", " ]]data ", S_OK },
{ "<a><![CDATA[<![CDATA[ data ]]]]></a>", "", "<![CDATA[ data ]]", S_OK },
{ "<a><![CDATA[\n \r\n \n\n ]]></a>", "", "\n \n \n\n ", S_OK, S_OK, 1 },
{ "<a><![CDATA[\r \r\r\n \n\n ]]></a>", "", "\n \n\n \n\n ", S_OK, S_OK, 1 },
{ "<a><![CDATA[\r\r \n\r \r \n\n ]]></a>", "", "\n\n \n\n \n \n\n ", S_OK },
{ NULL }
};
@ -1383,9 +1387,20 @@ static void test_read_cdata(void)
str = NULL;
hr = IXmlReader_GetValue(reader, &str, &len);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(len == strlen(test->value), "got %u\n", len);
str_exp = a2w(test->value);
ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
if (test->todo)
{
todo_wine {
ok(len == strlen(test->value), "got %u\n", len);
ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
}
}
else
{
ok(len == strlen(test->value), "got %u\n", len);
ok(!lstrcmpW(str, str_exp), "got %s\n", wine_dbgstr_w(str));
}
free_str(str_exp);
}