Commit 616fd820 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msxml3: Skip the first XML declaration in file generated by domdoc_save.

This is the last patch needed for Photoshop CS3 installer.
parent 82b2a833
...@@ -1690,7 +1690,7 @@ static HRESULT WINAPI domdoc_save( ...@@ -1690,7 +1690,7 @@ static HRESULT WINAPI domdoc_save(
{ {
domdoc *This = impl_from_IXMLDOMDocument2( iface ); domdoc *This = impl_from_IXMLDOMDocument2( iface );
HANDLE handle; HANDLE handle;
xmlChar *mem; xmlChar *mem, *p;
int size; int size;
HRESULT ret = S_OK; HRESULT ret = S_OK;
DWORD written; DWORD written;
...@@ -1738,7 +1738,23 @@ static HRESULT WINAPI domdoc_save( ...@@ -1738,7 +1738,23 @@ static HRESULT WINAPI domdoc_save(
} }
xmlDocDumpMemory(get_doc(This), &mem, &size); xmlDocDumpMemory(get_doc(This), &mem, &size);
if(!WriteFile(handle, mem, (DWORD)size, &written, NULL) || written != (DWORD)size)
/*
* libxml2 always adds XML declaration on top of the file and one for each processing instruction node in DOM tree.
* MSXML adds XML declaration only for processing instruction nodes.
* We skip the first XML declaration generated by libxml2 to get exactly what we need.
*/
p = mem;
if(size > 2 && p[0] == '<' && p[1] == '?') {
while(p < mem+size && (p[0] != '?' || p[1] != '>'))
p++;
p += 2;
while(p < mem+size && isspace(*p))
p++;
size -= p-mem;
}
if(!WriteFile(handle, p, (DWORD)size, &written, NULL) || written != (DWORD)size)
{ {
WARN("write error\n"); WARN("write error\n");
ret = S_FALSE; ret = S_FALSE;
......
...@@ -3304,9 +3304,7 @@ static void test_DocumentSaveToFile(void) ...@@ -3304,9 +3304,7 @@ static void test_DocumentSaveToFile(void)
ReadFile(file, buffer, sizeof(buffer), &read, NULL); ReadFile(file, buffer, sizeof(buffer), &read, NULL);
ok(read != 0, "could not read file\n"); ok(read != 0, "could not read file\n");
todo_wine {
ok(buffer[0] != '<' || buffer[1] != '?', "File contains processing instruction\n"); ok(buffer[0] != '<' || buffer[1] != '?', "File contains processing instruction\n");
}
DeleteFile("test.xml"); DeleteFile("test.xml");
} }
......
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