From 1ea39f99ede16180bcac6dce66622894eae02fb8 Mon Sep 17 00:00:00 2001 From: EvgeniyIgol Date: Mon, 27 Jan 2025 09:29:46 +0300 Subject: [PATCH] Fix bug 72174 - fix processing instruction in custom xml --- word/Editor/custom-xml/custom-xml.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/word/Editor/custom-xml/custom-xml.js b/word/Editor/custom-xml/custom-xml.js index adadbeea6a..2bd517edaa 100644 --- a/word/Editor/custom-xml/custom-xml.js +++ b/word/Editor/custom-xml/custom-xml.js @@ -89,9 +89,21 @@ }; CustomXml.prototype.addContentByXMLString = function (strCustomXml) { + let nXmlHeaderStart = strCustomXml.indexOf('', nXmlHeaderStart); + let strXmlHeader = null; + if (nXmlHeaderStart !== -1 && nXmlHeaderEnd !== -1) + { + strXmlHeader = strCustomXml.substring(nXmlHeaderStart, nXmlHeaderEnd + "?>".length); + strCustomXml = strCustomXml.substring(nXmlHeaderEnd + '?>'.length, strCustomXml.length); + } + let oStax = new StaxParser(strCustomXml), rootContent = new CustomXmlContent(null); + if (strXmlHeader !== null) + rootContent.xmlQuestionHeader = strXmlHeader; + while (oStax.Read()) { switch (oStax.GetEventType()) { @@ -130,6 +142,7 @@ this.content = []; this.attribute = {}; this.textContent = ""; + this.xmlQuestionHeader = null; this.addAttribute = function (name, value) { @@ -178,7 +191,9 @@ if (!content.name) { - writer.WriteXmlString("\n"); + if (content.xmlQuestionHeader !== null) + writer.WriteXmlString(content.xmlQuestionHeader + "\n"); + current = content.content[0]; } else