diff --git a/src/core/xml_parser.js b/src/core/xml_parser.js index bf053f156..be0877b47 100644 --- a/src/core/xml_parser.js +++ b/src/core/xml_parser.js @@ -145,6 +145,7 @@ class XMLParserBase { pos < s.length && !isWhitespace(s, pos) && s[pos] !== ">" && + s[pos] !== "?" && s[pos] !== "/" ) { ++pos; diff --git a/test/unit/xml_spec.js b/test/unit/xml_spec.js index 1b653fa84..eb2b920bd 100644 --- a/test/unit/xml_spec.js +++ b/test/unit/xml_spec.js @@ -13,8 +13,8 @@ * limitations under the License. */ +import { SimpleXMLParser, XMLParserBase } from "../../src/core/xml_parser.js"; import { parseXFAPath } from "../../src/core/core_utils.js"; -import { SimpleXMLParser } from "../../src/core/xml_parser.js"; describe("XML", function () { describe("searchNode", function () { @@ -108,4 +108,28 @@ describe("XML", function () { ); }); }); + + it("should parse processing instructions", function () { + const xml = ` + + + + + `; + const pi = []; + + class MyParser extends XMLParserBase { + onPi(name, value) { + pi.push([name, value]); + } + } + + new MyParser().parseXml(xml); + + expect(pi).toEqual([ + ["foo", "bar"], + ["foo", "bar oof"], + ["foo", ""], + ]); + }); });