Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 2.9.0 to 2.9.1

32

bin/parser.js

@@ -46,2 +46,3 @@ var getAllMatches = require("./util").getAllMatches;

//xmlData = xmlData.replace(/>(\s+)/g, ">");//Remove spaces and make it single line.
xmlData = xmlData.replace(/<!--(.|\n)*?-->/g, "");//Remove single and multiline comments
var tags = getAllMatches(xmlData,tagsRegx);

@@ -75,7 +76,3 @@ var xmlObj = new xmlNode('!xml');

}else{
if(val !== undefined && val != null){
childNode.val = val;
}else{
childNode.val = "";
}
childNode.val = val;
}

@@ -125,2 +122,5 @@ currentNode.addChild(childNode);

if(tags.length === 2) {
if(tags[0] === "xmlns") {
return "";
}
tagname = prefix + tags[1];

@@ -136,2 +136,3 @@ }

val = "" + val ;
val = val.replace("\n"," ");
}else{

@@ -158,3 +159,3 @@ if(val.indexOf(".") !== -1){

var attrsRegx = new RegExp("([\\w\\-\\.\\:]+)\\s*=\\s*(['\"])(.*?)\\2","g");
var attrsRegx = new RegExp("([\\w\\-\\.\\:]+)\\s*=\\s*(['\"])((.|\n)*?)\\2","gm");
function buildAttributesArr(attrStr,ignore,prefix,attrNodeName,ignoreNS,conversion){

@@ -167,11 +168,16 @@ attrStr = attrStr || attrStr.trim();

var attrs = {};
var attrsCollection = attrs;
if(attrNodeName && matches.length){
attrsCollection = attrs[attrNodeName] = {};
}
for (var i = 0; i < matches.length; i++) {
var attrName = prefix + resolveNameSpace( matches[i][1],ignoreNS);
attrsCollection[attrName] = parseValue(matches[i][3],conversion);
var attrName = resolveNameSpace(matches[i][1],ignoreNS);
if(attrName.length && attrName !== "xmlns") {
attrs[prefix + attrName] = parseValue(matches[i][3], conversion);
}
}
if(!Object.keys(attrs).length){
return;
}
if(attrNodeName){
var attrCollection = {};
attrCollection[attrNodeName] = attrs;
return attrCollection;
}
return attrs;

@@ -178,0 +184,0 @@ }

@@ -181,6 +181,3 @@ var util = require("./util");

startChar = attrStr[i++];
/*if(startChar !== "'" || startChar !== '"'){
return false;
}*/
var attrVal = "";

@@ -194,2 +191,6 @@ for(;i < attrStr.length && attrStr[i] !== startChar; i++) {

if(startChar !== ""){
i++;
if(i<attrStr.length && (attrStr[i] !== " " && attrStr[i] !== "\t") ){//when no spce between 2 attributes : a="sd"b="saf"
return false;
}
startChar = "";

@@ -196,0 +197,0 @@ }

@@ -47,2 +47,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.parser = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

//xmlData = xmlData.replace(/>(\s+)/g, ">");//Remove spaces and make it single line.
xmlData = xmlData.replace(/<!--(.|\n)*?-->/g, "");//Remove single and multiline comments
var tags = getAllMatches(xmlData,tagsRegx);

@@ -76,7 +77,3 @@ var xmlObj = new xmlNode('!xml');

}else{
if(val !== undefined && val != null){
childNode.val = val;
}else{
childNode.val = "";
}
childNode.val = val;
}

@@ -126,2 +123,5 @@ currentNode.addChild(childNode);

if(tags.length === 2) {
if(tags[0] === "xmlns") {
return "";
}
tagname = prefix + tags[1];

@@ -137,2 +137,3 @@ }

val = "" + val ;
val = val.replace("\n"," ");
}else{

@@ -159,3 +160,3 @@ if(val.indexOf(".") !== -1){

var attrsRegx = new RegExp("([\\w\\-\\.\\:]+)\\s*=\\s*(['\"])(.*?)\\2","g");
var attrsRegx = new RegExp("([\\w\\-\\.\\:]+)\\s*=\\s*(['\"])((.|\n)*?)\\2","gm");
function buildAttributesArr(attrStr,ignore,prefix,attrNodeName,ignoreNS,conversion){

@@ -168,11 +169,16 @@ attrStr = attrStr || attrStr.trim();

var attrs = {};
var attrsCollection = attrs;
if(attrNodeName && matches.length){
attrsCollection = attrs[attrNodeName] = {};
}
for (var i = 0; i < matches.length; i++) {
var attrName = prefix + resolveNameSpace( matches[i][1],ignoreNS);
attrsCollection[attrName] = parseValue(matches[i][3],conversion);
var attrName = resolveNameSpace(matches[i][1],ignoreNS);
if(attrName.length && attrName !== "xmlns") {
attrs[prefix + attrName] = parseValue(matches[i][3], conversion);
}
}
if(!Object.keys(attrs).length){
return;
}
if(attrNodeName){
var attrCollection = {};
attrCollection[attrNodeName] = attrs;
return attrCollection;
}
return attrs;

@@ -420,6 +426,3 @@ }

startChar = attrStr[i++];
/*if(startChar !== "'" || startChar !== '"'){
return false;
}*/
var attrVal = "";

@@ -433,2 +436,6 @@ for(;i < attrStr.length && attrStr[i] !== startChar; i++) {

if(startChar !== ""){
i++;
if(i<attrStr.length && (attrStr[i] !== " " && attrStr[i] !== "\t") ){//when no spce between 2 attributes : a="sd"b="saf"
return false;
}
startChar = "";

@@ -435,0 +442,0 @@ }

{
"name": "fast-xml-parser",
"version": "2.9.0",
"version": "2.9.1",
"description": "Validate XML or Parse XML to JS/JSON very fast without C/C++ based libraries",

@@ -9,4 +9,4 @@ "main": "./bin/parser.js",

"bundle": "browserify bin/parser.js --s parser > lib/parser.js",
"coverage": "node ./benchmark/perfTest.js; istanbul cover jasmine --captureExceptions spec/*spec.js;",
"coverage:check": "node ./node_modules/istanbul/lib/cli.js check-coverage --branch 90 --statement 90"
"coverage": "node ./benchmark/perfTest.js; istanbul cover -x \"spec/*spec.js\" jasmine spec/*spec.js;",
"coverage:check": "istanbul check-coverage --branch 90 --statement 90"
},

@@ -62,10 +62,11 @@ "bin": {

"benchmark": "^2.1.4",
"browserify": "^14.1.0",
"browserify": "^15.1.0",
"coveralls": "^3.0.0",
"http-server": "^0.10.0",
"http-server": "^0.11.1",
"istanbul": "^0.4.5",
"jasmine": "^2.6.0",
"jasmine-core": "^2.5.2",
"jasmine": "^2.8.0",
"jasmine-core": "^2.8.0",
"portfinder": "^1.0.13",
"zombie": "^5.0.7"
}
}
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