Skip to content
Open
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
9 changes: 9 additions & 0 deletions spec/validator_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ describe("XML Validator", function () {
});
});

it("should not validate XML declaration inside an element", function () {
validate("<foo><?xml version=\"1.0\"?></foo>", {
InvalidXml: "XML declaration allowed only at the start of the document."
});
validate("<foo>bar<?xml?></foo>", {
InvalidXml: "XML declaration allowed only at the start of the document."
});
});

it("should not validate XML with prolog only", function () {
validate("<?xml version=\"1.0\" standalone=\"yes\" ?><!--some comment - end in this line-->", {
InvalidXml: "Start tag expected."
Expand Down
2 changes: 1 addition & 1 deletion src/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export function validate(xmlData, options) {
i = readCommentAndCDATA(xmlData, i);
continue;
} else if (xmlData[i + 1] === '?') {
i = readPI(xmlData, ++i);
i = readPI(xmlData, i + 2);
if (i.err) return i;
} else {
break;
Expand Down