Nikolay Sivov : xmllite: Partially implement value normalization for CDATA sections.

Alexandre Julliard julliard at winehq.org
Tue Mar 26 15:11:11 CDT 2013


Module: wine
Branch: master
Commit: 2bdaffd879439a04827a8ffae6496d76fefcbfdc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2bdaffd879439a04827a8ffae6496d76fefcbfdc

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Sun Mar 24 00:04:12 2013 +0400

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 e8f97f0..3d0b4a8 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 520ce71..fad3d41 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[] = {
     { "<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);
         }
 




More information about the wine-cvs mailing list