From 6d5eef9c94b36f5bdfcbdef4c3fb705f9ebb780e Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Fri, 27 Mar 2020 15:47:39 +0100 Subject: [PATCH] webservices: Accept empty namespace in attribute type mapping. Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/webservices/reader.c | 21 ++++++++++++++++++--- dlls/webservices/tests/reader.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c index 119043f7057..4d37a38a8ac 100644 --- a/dlls/webservices/reader.c +++ b/dlls/webservices/reader.c @@ -4343,9 +4343,24 @@ static HRESULT get_text( struct reader *reader, WS_TYPE_MAPPING mapping, const W { case WS_ATTRIBUTE_TYPE_MAPPING: { - ULONG index; - if (!(*found = find_attribute( reader, localname, ns, &index ))) return S_OK; - return get_attribute_text( reader, index, ret ); + ULONG i; + WS_XML_ELEMENT_NODE *elem = &reader->current->hdr; + + *found = FALSE; + for (i = 0; i < elem->attributeCount; i++) + { + const WS_XML_STRING *localname2 = elem->attributes[i]->localName; + const WS_XML_STRING *ns2 = elem->attributes[i]->ns; + + if (cmp_name( localname->bytes, localname->length, localname2->bytes, localname2->length )) continue; + if (!ns->length || !cmp_name( ns->bytes, ns->length, ns2->bytes, ns2->length )) + { + *found = TRUE; + break; + } + } + if (!*found) return S_OK; + return get_attribute_text( reader, i, ret ); } case WS_ELEMENT_TYPE_MAPPING: case WS_ELEMENT_CONTENT_TYPE_MAPPING: diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c index ef6fd8808ec..733ebe3eb17 100644 --- a/dlls/webservices/tests/reader.c +++ b/dlls/webservices/tests/reader.c @@ -2556,7 +2556,8 @@ static void test_cdata(void) static void test_WsFindAttribute(void) { static const char test[] = ""; - WS_XML_STRING ns = {0, NULL}, localname = {4, (BYTE *)"attr"}; + static const char test2[] = ""; + WS_XML_STRING ns = {0, NULL}, ns2 = {2, (BYTE *)"ns"}, localname = {4, (BYTE *)"attr"}; WS_XML_STRING localname2 = {5, (BYTE *)"attr2"}, localname3 = {5, (BYTE *)"attr3"}; WS_XML_READER *reader; ULONG index; @@ -2638,6 +2639,32 @@ static void test_WsFindAttribute(void) ok( hr == S_FALSE, "got %08x\n", hr ); ok( index == ~0u, "got %u\n", index ); + hr = set_input( reader, test2, sizeof(test2) - 1 ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsReadNode( reader, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + index = 0xdeadbeef; + hr = WsFindAttribute( reader, &localname, &ns, TRUE, &index, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( !index, "got %u\n", index ); + + hr = WsFindAttribute( reader, &localname2, &ns2, TRUE, &index, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsFindAttribute( reader, &localname2, &ns, TRUE, &index, NULL ); + ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr ); + + hr = set_input( reader, test2, sizeof(test2) - 1 ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsReadNode( reader, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsFindAttribute( reader, &localname, &ns2, TRUE, &index, NULL ); + ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr ); + WsFreeReader( reader ); } -- 2.11.4.GIT