From 2bdaffd879439a04827a8ffae6496d76fefcbfdc Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sun, 24 Mar 2013 00:04:12 +0400 Subject: [PATCH] xmllite: Partially implement value normalization for CDATA sections. --- dlls/xmllite/reader.c | 6 ++++++ dlls/xmllite/tests/reader.c | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c index e8f97f0eb2e..3d0b4a8a26d 100644 --- a/dlls/xmllite/reader.c +++ b/dlls/xmllite/reader.c @@ -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++; } diff --git a/dlls/xmllite/tests/reader.c b/dlls/xmllite/tests/reader.c index 520ce71e8d9..fad3d412856 100644 --- a/dlls/xmllite/tests/reader.c +++ b/dlls/xmllite/tests/reader.c @@ -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[] = { { "", "", " ]]data ", S_OK }, { "", "", "", "", "\n \n \n\n ", S_OK, S_OK, 1 }, + { "", "", "\n \n\n \n\n ", S_OK, S_OK, 1 }, + { "", "", "\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); }