Module: wine Branch: master Commit: acf6b4eeec356ced33a33a77936e2780634d71d8 URL: http://source.winehq.org/git/wine.git/?a=commit;h=acf6b4eeec356ced33a33a7793...
Author: Owen Rudge orudge@codeweavers.com Date: Thu May 18 22:41:50 2017 +0100
webservices: Write empty prefix if "prefix" is NULL and "ns" is empty.
Signed-off-by: Owen Rudge orudge@codeweavers.com Signed-off-by: Hans Leidekker hans@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/webservices/tests/writer.c | 22 ++++++++++++++++++++++ dlls/webservices/writer.c | 5 ++--- 2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/dlls/webservices/tests/writer.c b/dlls/webservices/tests/writer.c index 4dfa1db..aa33b76 100644 --- a/dlls/webservices/tests/writer.c +++ b/dlls/webservices/tests/writer.c @@ -538,6 +538,28 @@ static void test_WsWriteStartAttribute(void) ok( hr == S_OK, "got %08x\n", hr ); check_output( writer, "<p:str len="" xmlns:p="ns"/>", __LINE__ );
+ hr = set_output( writer ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsWriteStartElement( writer, &prefix, &localname, &ns, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsWriteStartAttribute( writer, NULL, &localname2, &empty, FALSE, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsWriteEndAttribute( writer, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsWriteStartAttribute( writer, NULL, &localname, &ns, FALSE, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsWriteEndAttribute( writer, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsWriteEndElement( writer, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + check_output( writer, "<p:str len="" p:str="" xmlns:p="ns"/>", __LINE__ ); + WsFreeWriter( writer ); }
diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c index 421b79d..2b5affc 100644 --- a/dlls/webservices/writer.c +++ b/dlls/webservices/writer.c @@ -521,12 +521,11 @@ static HRESULT write_attribute( struct writer *writer, WS_XML_ATTRIBUTE *attr ) { WS_XML_UTF8_TEXT *text = (WS_XML_UTF8_TEXT *)attr->value; unsigned char quote = attr->singleQuote ? ''' : '"'; - const WS_XML_STRING *prefix; + const WS_XML_STRING *prefix = NULL; ULONG size; HRESULT hr;
if (attr->prefix) prefix = attr->prefix; - else prefix = writer->current->hdr.prefix;
/* ' prefix:attr="value"' */
@@ -930,7 +929,7 @@ static HRESULT write_add_attribute( struct writer *writer, const WS_XML_STRING *
if (!(attr = heap_alloc_zero( sizeof(*attr) ))) return E_OUTOFMEMORY;
- if (!prefix) prefix = elem->prefix; + if (!prefix && ns->length > 0) prefix = elem->prefix;
attr->singleQuote = !!single; if (prefix && !(attr->prefix = alloc_xml_string( prefix->bytes, prefix->length )))