Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Note: If you find missing information about particular minor version, that version must have been changed without any functional change in this library.

**4.0.13 / 2023-01-07**
* preserveorder formatting (By [mdeknowis](https://github.com/mdeknowis))
* support `transformAttributeName` (By [Erik Rothoff Andersson](https://github.com/erkie))

**4.0.12 / 2022-11-19**
* fix typescript

Expand Down
2 changes: 1 addition & 1 deletion lib/fxbuilder.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/fxbuilder.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/fxp.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/fxp.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/fxparser.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/fxparser.min.js.map

Large diffs are not rendered by default.

36 changes: 15 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fast-xml-parser",
"version": "4.0.12",
"version": "4.0.13",
"description": "Validate XML, Parse XML, Build XML without C/C++ based libraries",
"main": "./src/fxp.js",
"scripts": {
Expand Down
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);
});
});
});
4 changes: 2 additions & 2 deletions src/xmlbuilder/json2xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const defaultOptions = {
],
processEntities: true,
stopNodes: [],
transformTagName: false,
transformAttributeName: false,
// transformTagName: false,
// transformAttributeName: false,
};

function Builder(options) {
Expand Down
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
Loading