[PATCH v2 0/2] MR11016: msxml3: Don't indent endElement node since it changes text node content.
-- v2: msxml3: Don't indent endElement since it changes text node content. https://gitlab.winehq.org/wine/wine/-/merge_requests/11016
From: Piotr Caban <piotr@codeweavers.com> --- dlls/msxml3/mxwriter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c index 6b1cd4706cb..22841b791d1 100644 --- a/dlls/msxml3/mxwriter.c +++ b/dlls/msxml3/mxwriter.c @@ -2618,7 +2618,7 @@ HRESULT MXWriter_create(MSXML_VERSION version, void **ppObj) This->cdata = FALSE; This->indent = 0; This->text = FALSE; - This->newline = FALSE; + This->newline = TRUE; This->dest = NULL; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11016
From: Piotr Caban <piotr@codeweavers.com> --- dlls/msxml3/mxwriter.c | 3 --- dlls/msxml3/tests/saxreader.c | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c index 22841b791d1..d8d60e863b6 100644 --- a/dlls/msxml3/mxwriter.c +++ b/dlls/msxml3/mxwriter.c @@ -672,9 +672,6 @@ static inline void writer_inc_indent(mxwriter *This) static inline void writer_dec_indent(mxwriter *This) { if (This->indent) This->indent--; - /* depth is decreased only when element is closed, meaning it's not a text node - at this point */ - This->text = FALSE; } static void set_element_name(mxwriter *This, const WCHAR *name, int len) diff --git a/dlls/msxml3/tests/saxreader.c b/dlls/msxml3/tests/saxreader.c index 8a3d87401cb..824bf729656 100644 --- a/dlls/msxml3/tests/saxreader.c +++ b/dlls/msxml3/tests/saxreader.c @@ -4818,6 +4818,42 @@ static void test_mxwriter_characters(void) i++; } + /* test surrounding node indentation */ + hr = CoCreateInstance(&CLSID_MXXMLWriter, NULL, CLSCTX_INPROC_SERVER, + &IID_IMXWriter, (void**)&writer); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMXWriter_put_indent(writer, VARIANT_TRUE); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMXWriter_QueryInterface(writer, &IID_ISAXContentHandler, (void**)&content); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IMXWriter_put_omitXMLDeclaration(writer, VARIANT_TRUE); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = ISAXContentHandler_startDocument(content); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = ISAXContentHandler_startElement(content, L"", 0, L"", 0, L"a", 1, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = ISAXContentHandler_characters(content, L"test", 4); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = ISAXContentHandler_endElement(content, L"", 0, L"", 0, L"a", 1); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + V_VT(&dest) = VT_EMPTY; + hr = IMXWriter_get_output(writer, &dest); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(V_VT(&dest) == VT_BSTR, "got %d\n", V_VT(&dest)); + ok(!lstrcmpW(L"<a>test</a>", V_BSTR(&dest)), "got wrong content %s\n", wine_dbgstr_w(V_BSTR(&dest))); + VariantClear(&dest); + + ISAXContentHandler_Release(content); + IMXWriter_Release(writer); + free_bstrs(); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11016
On Thu May 28 17:19:55 2026 +0000, Piotr Caban wrote:
Yes, but do you think there's a value in duplicating the test both with indentation enabled and disabled? I think it makes sense to change existing test so it both tests what it was originally written for and also shows an error in indentation handling. I've pushed a version that adds new test instead of modifying existing one.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/11016#note_141534
On Thu May 28 17:27:46 2026 +0000, Piotr Caban wrote:
I've pushed a version that adds new test instead of modifying existing one. I know that 'newline' thing is definitely broken currently. For instance comments and most likely PIs should not always append a newline - only in epilog/prolog parts. When you are in document element there should be no extra newlines.
So I'd rather we start with more tests that show formatting issues and maybe this newline flag will have to be replaced by something else. The only cases that are interesting is writing before and after root element, and then of course in element with text nodes and without. All of that ran twice with different indent modes. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11016#note_141536
participants (3)
-
Nikolay Sivov (@nsivov) -
Piotr Caban -
Piotr Caban (@piotr)