Socket
Socket
Sign inDemoInstall

fast-xml-parser

Package Overview
Dependencies
Maintainers
1
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-xml-parser - npm Package Compare versions

Comparing version 4.0.8 to 4.0.9

8

CHANGELOG.md
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.8 / 2022-03-18**
**4.0.9 / 2022-07-10**
* fix #470: stop-tag can have self-closing tag with same name
* fix #472: stopNode can have any special tag inside
* Allow !ATTLIST and !NOTATION with DOCTYPE
* Add transformTagName option to transform tag names when parsing (#469) (By [Erik Rothoff Andersson](https://github.com/erkie))
**4.0.8 / 2022-05-28**
* Fix CDATA parsing returning empty string when value = 0 (#451) (By [ndelanou](https://github.com/ndelanou))

@@ -5,0 +11,0 @@ * Fix stopNodes when same tag appears inside node (#456) (By [patrickshipe](https://github.com/patrickshipe))

2

package.json
{
"name": "fast-xml-parser",
"version": "4.0.8",
"version": "4.0.9",
"description": "Validate XML, Parse XML, Build XML without C/C++ based libraries",

@@ -5,0 +5,0 @@ "main": "./src/fxp.js",

@@ -25,2 +25,3 @@ type X2jOptions = {

ignorePiTags: boolean;
transformTagName: ((tagName: string) => string) | false;
};

@@ -27,0 +28,0 @@ type strnumOptions = {

@@ -33,3 +33,4 @@ 'use strict';

processEntities: true,
stopNodes: []
stopNodes: [],
transformTagName: false,
};

@@ -36,0 +37,0 @@

@@ -41,2 +41,27 @@ //TODO: handle comments

i += 8;
}else if( hasBody &&
xmlData[i+1] === '!' &&
xmlData[i+2] === 'A' &&
xmlData[i+3] === 'T' &&
xmlData[i+4] === 'T' &&
xmlData[i+5] === 'L' &&
xmlData[i+6] === 'I' &&
xmlData[i+7] === 'S' &&
xmlData[i+8] === 'T'
){
//Not supported
i += 8;
}else if( hasBody &&
xmlData[i+1] === '!' &&
xmlData[i+2] === 'N' &&
xmlData[i+3] === 'O' &&
xmlData[i+4] === 'T' &&
xmlData[i+5] === 'A' &&
xmlData[i+6] === 'T' &&
xmlData[i+7] === 'I' &&
xmlData[i+8] === 'O' &&
xmlData[i+9] === 'N'
){
//Not supported
i += 9;
}else if( //comment

@@ -43,0 +68,0 @@ xmlData[i+1] === '!' &&

@@ -33,3 +33,4 @@

ignoreDeclaration: false,
ignorePiTags: false
ignorePiTags: false,
transformTagName: false,
};

@@ -36,0 +37,0 @@

@@ -196,2 +196,6 @@ 'use strict';

if(this.options.transformTagName) {
tagName = this.options.transformTagName(tagName);
}
if(currentNode){

@@ -261,3 +265,2 @@ textData = this.saveTextToParentTag(textData, currentNode, jPath);

}else {//Opening tag
let result = readTagExp(xmlData,i, this. options.removeNSPrefix);

@@ -268,2 +271,6 @@ let tagName= result.tagName;

let closeIndex = result.closeIndex;
if (this.options.transformTagName) {
tagName = this.options.transformTagName(tagName);
}

@@ -328,2 +335,6 @@ //save text as child node

}
if(this.options.transformTagName) {
tagName = this.options.transformTagName(tagName);
}

@@ -498,3 +509,3 @@ const childNode = new xmlNode(tagName);

if( xmlData[i] === "<"){
if (xmlData[i+1] === "/") {
if (xmlData[i+1] === "/") {//close tag
const closeIndex = findClosingIndex(xmlData, ">", i, `${tagName} is not closed`);

@@ -512,2 +523,11 @@ let closeTagName = xmlData.substring(i+2,closeIndex).trim();

i=closeIndex;
} else if(xmlData[i+1] === '?') {
const closeIndex = findClosingIndex(xmlData, "?>", i+1, "StopNode is not closed.")
i=closeIndex;
} else if(xmlData.substr(i + 1, 3) === '!--') {
const closeIndex = findClosingIndex(xmlData, "-->", i+3, "StopNode is not closed.")
i=closeIndex;
} else if(xmlData.substr(i + 1, 2) === '![') {
const closeIndex = findClosingIndex(xmlData, "]]>", i, "StopNode is not closed.") - 2;
i=closeIndex;
} else {

@@ -518,3 +538,3 @@ const tagData = readTagExp(xmlData, i, '>')

const openTagName = tagData && tagData.tagName;
if (openTagName === tagName) {
if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length-1] !== "/") {
openTagCount++;

@@ -521,0 +541,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc