Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	lib/fxp.min.js
#	lib/fxp.min.js.map
#	lib/fxparser.min.js
#	lib/fxparser.min.js.map
#	package-lock.json
#	package.json
  • Loading branch information
amitguptagwl committed Feb 2, 2023
2 parents c959d13 + 30624d7 commit ed962e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
9 changes: 8 additions & 1 deletion spec/entities_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ describe("XMLParser Entities", function() {
expect(result).toEqual(expected);
});

it("should not throw error when DTD comments contain '<' or '>'", function() {
const xmlData = `<!DOCTYPE greeting [<!-- < > < -->]>`;

const parser = new XMLParser();
parser.parse(xmlData);
});

it("should parse attributes having '>' in value", function() {
const xmlData = `
<?xml version="1.0" encoding="UTF-8"?>
Expand Down Expand Up @@ -525,4 +532,4 @@ describe("XMLParser External Entites", function() {

expect(result).toEqual(expected);
});
});
});
15 changes: 8 additions & 7 deletions src/xmlparser/DocTypeReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function readDocType(xmlData, i){
let hasBody = false, entity = false, comment = false;
let exp = "";
for(;i<xmlData.length;i++){
if (xmlData[i] === '<') {
if (xmlData[i] === '<' && !comment) {
if( hasBody &&
xmlData[i+1] === '!' &&
xmlData[i+2] === 'E' &&
Expand Down Expand Up @@ -78,14 +78,15 @@ function readDocType(xmlData, i){
if(comment){
if( xmlData[i - 1] === "-" && xmlData[i - 2] === "-"){
comment = false;
}else{
throw new Error(`Invalid XML comment in DOCTYPE`);
angleBracketsCount--;
}
}else if(entity){
parseEntityExp(exp, entities);
entity = false;
}else{
if(entity) {
parseEntityExp(exp, entities);
entity = false;
}
angleBracketsCount--;
}
angleBracketsCount--;
if (angleBracketsCount === 0) {
break;
}
Expand Down

0 comments on commit ed962e0

Please sign in to comment.