Hans Leidekker : webservices: Accept single quote as attribute value delimiter.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Oct 14 11:12:50 CDT 2015


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

Author: Hans Leidekker <hans at codeweavers.com>
Date:   Wed Oct 14 13:01:03 2015 +0200

webservices: Accept single quote as attribute value delimiter.

Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/webservices/reader.c       |  8 +++++---
 dlls/webservices/tests/reader.c | 23 +++++++++++++++++++++--
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c
index a8990d8..f85b5e7 100644
--- a/dlls/webservices/reader.c
+++ b/dlls/webservices/reader.c
@@ -746,7 +746,7 @@ static HRESULT read_attribute( struct reader *reader, WS_XML_ATTRIBUTE **ret )
 {
     WS_XML_ATTRIBUTE *attr;
     WS_XML_UTF8_TEXT *text;
-    unsigned int len = 0, ch, skip;
+    unsigned int len = 0, ch, skip, quote;
     const char *start;
     HRESULT hr = WS_E_INVALID_FORMAT;
 
@@ -775,7 +775,8 @@ static HRESULT read_attribute( struct reader *reader, WS_XML_ATTRIBUTE **ret )
     read_skip( reader, 1 );
 
     read_skip_whitespace( reader );
-    if (read_cmp( reader, "\"", 1 )) goto error;
+    if (read_cmp( reader, "\"", 1 ) && read_cmp( reader, "'", 1 )) goto error;
+    quote = read_utf8_char( reader, &skip );
     read_skip( reader, 1 );
 
     len = 0;
@@ -783,7 +784,7 @@ static HRESULT read_attribute( struct reader *reader, WS_XML_ATTRIBUTE **ret )
     for (;;)
     {
         if (!(ch = read_utf8_char( reader, &skip ))) goto error;
-        if (ch == '"') break;
+        if (ch == quote) break;
         read_skip( reader, skip );
         len += skip;
     }
@@ -795,6 +796,7 @@ static HRESULT read_attribute( struct reader *reader, WS_XML_ATTRIBUTE **ret )
         return E_OUTOFMEMORY;
     }
     attr->value = (WS_XML_TEXT *)text;
+    attr->singleQuote = (quote == '\'');
 
     *ret = attr;
     return S_OK;
diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c
index 0d32864..f4ac601 100644
--- a/dlls/webservices/tests/reader.c
+++ b/dlls/webservices/tests/reader.c
@@ -50,7 +50,7 @@ static const char data5[] =
 
 static const char data6[] =
     "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
-    "<text attr= \"value\" >test</text>";
+    "<text attr= \"value\" attr2='value2'>test</text>";
 
 static const char data8[] =
     "<node1><node2>test</node2></node1>";
@@ -872,7 +872,7 @@ static void test_WsReadNode(void)
         ok( elem->ns != NULL, "ns not set\n" );
         ok( !elem->ns->length, "got %u\n", elem->ns->length );
         ok( elem->ns->bytes != NULL, "bytes not set\n" );
-        ok( elem->attributeCount == 1, "got %u\n", elem->attributeCount );
+        ok( elem->attributeCount == 2, "got %u\n", elem->attributeCount );
         ok( elem->attributes != NULL, "attributes not set\n" );
         ok( !elem->isEmpty, "isEmpty not zero\n" );
 
@@ -894,6 +894,25 @@ static void test_WsReadNode(void)
         ok( attr->value->textType == WS_XML_TEXT_TYPE_UTF8, "got %u\n", attr->value->textType );
         ok( text->value.length == 5, "got %u\n", text->value.length );
         ok( !memcmp( text->value.bytes, "value", 5 ), "wrong data\n" );
+
+        attr = elem->attributes[1];
+        ok( attr->singleQuote == 1, "got %u\n", attr->singleQuote );
+        ok( !attr->isXmlNs, "got %u\n", attr->isXmlNs );
+        ok( attr->prefix != NULL, "prefix not set\n" );
+        ok( !attr->prefix->length, "got %u\n", attr->prefix->length );
+        ok( attr->prefix->bytes == NULL, "bytes set\n" );
+        ok( attr->localName != NULL, "localName not set\n" );
+        ok( attr->localName->length == 5, "got %u\n", attr->localName->length );
+        ok( !memcmp( attr->localName->bytes, "attr2", 5 ), "wrong data\n" );
+        ok( attr->ns != NULL, "ns not set\n" );
+        ok( !attr->ns->length, "got %u\n", attr->ns->length );
+        ok( attr->ns->bytes == NULL, "bytes set\n" );
+        ok( attr->value != NULL, "value not set\n" );
+
+        text = (WS_XML_UTF8_TEXT *)attr->value;
+        ok( attr->value->textType == WS_XML_TEXT_TYPE_UTF8, "got %u\n", attr->value->textType );
+        ok( text->value.length == 6, "got %u\n", text->value.length );
+        ok( !memcmp( text->value.bytes, "value2", 6 ), "wrong data\n" );
     }
 
     WsFreeReader( reader );




More information about the wine-cvs mailing list