Commit 3bc1bdae authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msxml3: Support disabled escaping mode when writing attribute values.

parent 622c94ac
......@@ -1019,19 +1019,20 @@ static HRESULT WINAPI SAXContentHandler_startElement(
if (attr)
{
int length, i, escape;
HRESULT hr;
INT length;
INT i;
hr = ISAXAttributes_getLength(attr, &length);
if (FAILED(hr)) return hr;
escape = This->props[MXWriter_DisableEscaping] == VARIANT_FALSE ||
(This->class_version == MSXML4 || This->class_version == MSXML6);
for (i = 0; i < length; i++)
{
static const WCHAR eqW[] = {'='};
const WCHAR *str;
WCHAR *escaped;
INT len = 0;
int len = 0;
hr = ISAXAttributes_getQName(attr, i, &str, &len);
if (FAILED(hr)) return hr;
......@@ -1046,9 +1047,14 @@ static HRESULT WINAPI SAXContentHandler_startElement(
hr = ISAXAttributes_getValue(attr, i, &str, &len);
if (FAILED(hr)) return hr;
escaped = get_escaped_string(str, EscapeValue, &len);
write_output_buffer_quoted(This->buffer, escaped, len);
heap_free(escaped);
if (escape)
{
WCHAR *escaped = get_escaped_string(str, EscapeValue, &len);
write_output_buffer_quoted(This->buffer, escaped, len);
heap_free(escaped);
}
else
write_output_buffer_quoted(This->buffer, str, len);
}
}
......
......@@ -2832,9 +2832,10 @@ static void test_mxwriter_startenddocument(void)
enum startendtype
{
StartElement,
EndElement,
StartEndElement
StartElement = 0x001,
EndElement = 0x010,
StartEndElement = 0x011,
DisableEscaping = 0x100
};
struct writer_startendelement_t {
......@@ -2850,6 +2851,7 @@ struct writer_startendelement_t {
static const char startelement_xml[] = "<uri:local a:attr1=\"a1\" attr2=\"a2\" attr3=\"&lt;&amp;&quot;&gt;\">";
static const char startendelement_xml[] = "<uri:local a:attr1=\"a1\" attr2=\"a2\" attr3=\"&lt;&amp;&quot;&gt;\"/>";
static const char startendelement_noescape_xml[] = "<uri:local a:attr1=\"a1\" attr2=\"a2\" attr3=\"<&\">\"/>";
static const struct writer_startendelement_t writer_startendelement[] = {
/* 0 */
......@@ -2948,6 +2950,13 @@ static const struct writer_startendelement_t writer_startendelement[] = {
{ &CLSID_MXXMLWriter40, StartEndElement, "", "", "", "</>", S_OK },
/* 75 */
{ &CLSID_MXXMLWriter60, StartEndElement, "", "", "", "</>", S_OK },
/* with disabled output escaping */
{ &CLSID_MXXMLWriter, StartEndElement | DisableEscaping, "uri", "local", "uri:local", startendelement_noescape_xml, S_OK, &saxattributes },
{ &CLSID_MXXMLWriter30, StartEndElement | DisableEscaping, "uri", "local", "uri:local", startendelement_noescape_xml, S_OK, &saxattributes },
{ &CLSID_MXXMLWriter40, StartEndElement | DisableEscaping, "uri", "local", "uri:local", startendelement_xml, S_OK, &saxattributes },
{ &CLSID_MXXMLWriter60, StartEndElement | DisableEscaping, "uri", "local", "uri:local", startendelement_xml, S_OK, &saxattributes },
{ NULL }
};
......@@ -2998,23 +3007,21 @@ static void test_mxwriter_startendelement_batch(const struct writer_startendelem
hr = ISAXContentHandler_startDocument(content);
EXPECT_HR(hr, S_OK);
if (table->type == StartElement)
{
hr = ISAXContentHandler_startElement(content, _bstr_(table->uri), lstrlen(table->uri),
_bstr_(table->local_name), lstrlen(table->local_name), _bstr_(table->qname), lstrlen(table->qname), table->attr);
ok(hr == table->hr, "test %d: got 0x%08x, expected 0x%08x\n", i, hr, table->hr);
}
else if (table->type == EndElement)
if (table->type & DisableEscaping)
{
hr = ISAXContentHandler_endElement(content, _bstr_(table->uri), lstrlen(table->uri),
_bstr_(table->local_name), lstrlen(table->local_name), _bstr_(table->qname), lstrlen(table->qname));
ok(hr == table->hr, "test %d: got 0x%08x, expected 0x%08x\n", i, hr, table->hr);
hr = IMXWriter_put_disableOutputEscaping(writer, VARIANT_TRUE);
EXPECT_HR(hr, S_OK);
}
else
if (table->type & StartElement)
{
hr = ISAXContentHandler_startElement(content, _bstr_(table->uri), lstrlen(table->uri),
_bstr_(table->local_name), lstrlen(table->local_name), _bstr_(table->qname), lstrlen(table->qname), table->attr);
ok(hr == table->hr, "test %d: got 0x%08x, expected 0x%08x\n", i, hr, table->hr);
}
if (table->type & EndElement)
{
hr = ISAXContentHandler_endElement(content, _bstr_(table->uri), lstrlen(table->uri),
_bstr_(table->local_name), lstrlen(table->local_name), _bstr_(table->qname), lstrlen(table->qname));
ok(hr == table->hr, "test %d: got 0x%08x, expected 0x%08x\n", i, hr, table->hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment