Skip to content

Commit

Permalink
Fix bug 72174
Browse files Browse the repository at this point in the history
- fix processing instruction in custom xml
  • Loading branch information
IgolJack authored and KirillovIlya committed Jan 28, 2025
1 parent 5afb081 commit 1ea39f9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion word/Editor/custom-xml/custom-xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,21 @@
};
CustomXml.prototype.addContentByXMLString = function (strCustomXml)
{
let nXmlHeaderStart = strCustomXml.indexOf('<?', 0);
let nXmlHeaderEnd = 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()) {
Expand Down Expand Up @@ -130,6 +142,7 @@
this.content = [];
this.attribute = {};
this.textContent = "";
this.xmlQuestionHeader = null;

this.addAttribute = function (name, value)
{
Expand Down Expand Up @@ -178,7 +191,9 @@

if (!content.name)
{
writer.WriteXmlString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
if (content.xmlQuestionHeader !== null)
writer.WriteXmlString(content.xmlQuestionHeader + "\n");

current = content.content[0];
}
else
Expand Down

0 comments on commit 1ea39f9

Please sign in to comment.