🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

stream-xml

Package Overview
Dependencies
Maintainers
0
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-xml - npm Package Compare versions

Comparing version

to
0.6.0

40

dist/parser.js

@@ -15,4 +15,6 @@ "use strict";

const EQUAL = "=".charCodeAt(0);
const QUOTE = `"`.charCodeAt(0);
const DOUBLE_QUOTE = `"`.charCodeAt(0);
const SINGLE_QUOTE = `'`.charCodeAt(0);
const isWhitespace = (char) => char === BLANK || char === TAB || char === RETURN || char === NEWLINE;
const isQuote = (char) => char === SINGLE_QUOTE || char === DOUBLE_QUOTE;
/**

@@ -38,2 +40,8 @@ * Checks if two Uint8Arrays are equal

})(StateType || (StateType = {}));
var OpeningQuoteType;
(function (OpeningQuoteType) {
OpeningQuoteType[OpeningQuoteType["Unknown"] = 0] = "Unknown";
OpeningQuoteType[OpeningQuoteType["Single"] = 1] = "Single";
OpeningQuoteType[OpeningQuoteType["Double"] = 2] = "Double";
})(OpeningQuoteType || (OpeningQuoteType = {}));
class Parser {

@@ -52,2 +60,3 @@ #callbacks = [];

#resetPos = 0;
#lastOpeningQuoteType = OpeningQuoteType.Unknown;
#textDecoder;

@@ -192,3 +201,7 @@ #textEncoder = new TextEncoder();

}
else if (char === QUOTE) {
else if (isQuote(char)) {
this.#lastOpeningQuoteType =
char === SINGLE_QUOTE
? OpeningQuoteType.Single
: OpeningQuoteType.Double;
this.setState(StateType.Quoted);

@@ -209,3 +222,9 @@ }

case StateType.Quoted: {
if (char === QUOTE) {
if (this.#lastOpeningQuoteType === OpeningQuoteType.Unknown) {
throw new Error("In quotes, but opening quote type was not set");
}
if ((this.#lastOpeningQuoteType === OpeningQuoteType.Single &&
char === SINGLE_QUOTE) ||
(this.#lastOpeningQuoteType === OpeningQuoteType.Double &&
char === DOUBLE_QUOTE)) {
this.setState(StateType.Attributes);

@@ -261,2 +280,3 @@ }

let state = { type: "INIT" };
let lastOpeningQuoteType = OpeningQuoteType.Unknown;
// parse attributes into object

@@ -294,3 +314,7 @@ const attrs = {};

case "VALUE": {
if (i === state.startPos && char === QUOTE) {
if (i === state.startPos && isQuote(char)) {
lastOpeningQuoteType =
char === SINGLE_QUOTE
? OpeningQuoteType.Single
: OpeningQuoteType.Double;
state = { type: "QUOTED_VALUE", startPos: i + 1 };

@@ -304,3 +328,9 @@ }

case "QUOTED_VALUE": {
if (char === QUOTE) {
if (lastOpeningQuoteType === OpeningQuoteType.Unknown) {
throw new Error("In quotes, but opening quote type was not set");
}
if ((lastOpeningQuoteType === OpeningQuoteType.Single &&
char === SINGLE_QUOTE) ||
(lastOpeningQuoteType === OpeningQuoteType.Double &&
char === DOUBLE_QUOTE)) {
addValueAndReset(state.startPos, i);

@@ -307,0 +337,0 @@ }

2

package.json

@@ -8,3 +8,3 @@ {

},
"version": "0.5.2",
"version": "0.6.0",
"main": "dist/index.js",

@@ -11,0 +11,0 @@ "license": "MIT",