diff --git a/lib/saxes.js b/lib/saxes.js index f6516011..17e85b83 100644 --- a/lib/saxes.js +++ b/lib/saxes.js @@ -543,6 +543,13 @@ class SAXParser { this.piTarget = this.piBody = ""; this.state = S_TEXT; } + else if (c === "?") { + // We ran into ?? as part of a processing instruction. We initially + // took the first ? as a sign that the PI was ending, but it is + // not. So we have to add it to the body but we take the new ? as a + // sign that the PI is ending. + this.piBody += "?"; + } else { this.piBody += `?${c}`; this.state = S_PI_BODY;