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>
oldstable
Owen Rudge 2017-05-18 22:41:50 +01:00 committed by Alexandre Julliard
parent 53bf72e266
commit acf6b4eeec
2 changed files with 24 additions and 3 deletions

View File

@ -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 );
}

View File

@ -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 )))