Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle PI with no value in xml parser #13394

Merged
merged 1 commit into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/xml_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class XMLParserBase {
pos < s.length &&
!isWhitespace(s, pos) &&
s[pos] !== ">" &&
s[pos] !== "?" &&
s[pos] !== "/"
) {
++pos;
Expand Down
26 changes: 25 additions & 1 deletion test/unit/xml_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -108,4 +108,28 @@ describe("XML", function () {
);
});
});

it("should parse processing instructions", function () {
const xml = `
<a>
<?foo bar?>
<?foo bar oof?>
<?foo?>
</a>`;
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", ""],
]);
});
});