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

@azure/core-xml

Package Overview
Dependencies
Maintainers
1
Versions
254
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/core-xml - npm Package Compare versions

Comparing version 1.4.2-alpha.20240322.2 to 1.4.2-alpha.20240329.3

36

dist/browser/xml.js

@@ -28,11 +28,12 @@ // Copyright (c) Microsoft Corporation.

export function parseXML(str, opts = {}) {
var _a, _b, _c, _d, _e, _f;
try {
const updatedOptions = {
rootName: opts.rootName ?? "",
includeRoot: opts.includeRoot ?? false,
xmlCharKey: opts.xmlCharKey ?? XML_CHARKEY,
cdataPropName: opts.cdataPropName ?? "__cdata",
stopNodes: opts.stopNodes ?? [],
rootName: (_a = opts.rootName) !== null && _a !== void 0 ? _a : "",
includeRoot: (_b = opts.includeRoot) !== null && _b !== void 0 ? _b : false,
xmlCharKey: (_c = opts.xmlCharKey) !== null && _c !== void 0 ? _c : XML_CHARKEY,
cdataPropName: (_d = opts.cdataPropName) !== null && _d !== void 0 ? _d : "__cdata",
stopNodes: (_e = opts.stopNodes) !== null && _e !== void 0 ? _e : [],
};
const dom = parser.parseFromString((ttPolicy?.createHTML(str) ?? str), "application/xml");
const dom = parser.parseFromString(((_f = ttPolicy === null || ttPolicy === void 0 ? void 0 : ttPolicy.createHTML(str)) !== null && _f !== void 0 ? _f : str), "application/xml");
throwIfError(dom);

@@ -54,8 +55,9 @@ let obj;

function getErrorNamespace() {
var _a, _b;
if (errorNS === undefined) {
try {
const invalidXML = (ttPolicy?.createHTML("INVALID") ?? "INVALID");
const invalidXML = ((_a = ttPolicy === null || ttPolicy === void 0 ? void 0 : ttPolicy.createHTML("INVALID")) !== null && _a !== void 0 ? _a : "INVALID");
errorNS =
parser.parseFromString(invalidXML, "text/xml").getElementsByTagName("parsererror")[0]
.namespaceURI ?? "";
(_b = parser.parseFromString(invalidXML, "text/xml").getElementsByTagName("parsererror")[0]
.namespaceURI) !== null && _b !== void 0 ? _b : "";
}

@@ -90,2 +92,3 @@ catch (ignored) {

function domToObject(node, options) {
var _a;
let result = {};

@@ -120,7 +123,7 @@ const childNodeCount = node.childNodes.length;

// Check if CData
if (child?.nodeType === Node.CDATA_SECTION_NODE) {
if ((child === null || child === void 0 ? void 0 : child.nodeType) === Node.CDATA_SECTION_NODE) {
// Already in the CDATA
result = child.textContent;
}
else if (child?.firstChild?.nodeType === Node.CDATA_SECTION_NODE) {
else if (((_a = child === null || child === void 0 ? void 0 : child.firstChild) === null || _a === void 0 ? void 0 : _a.nodeType) === Node.CDATA_SECTION_NODE) {
// Look if child is CDATA

@@ -148,8 +151,9 @@ result[child.nodeName] = child.textContent;

export function stringifyXML(content, opts = {}) {
var _a, _b, _c, _d, _e;
const updatedOptions = {
rootName: opts.rootName ?? "root",
includeRoot: opts.includeRoot ?? false,
xmlCharKey: opts.xmlCharKey ?? XML_CHARKEY,
cdataPropName: opts.cdataPropName ?? "__cdata",
stopNodes: opts.stopNodes ?? [],
rootName: (_a = opts.rootName) !== null && _a !== void 0 ? _a : "root",
includeRoot: (_b = opts.includeRoot) !== null && _b !== void 0 ? _b : false,
xmlCharKey: (_c = opts.xmlCharKey) !== null && _c !== void 0 ? _c : XML_CHARKEY,
cdataPropName: (_d = opts.cdataPropName) !== null && _d !== void 0 ? _d : "__cdata",
stopNodes: (_e = opts.stopNodes) !== null && _e !== void 0 ? _e : [],
};

@@ -156,0 +160,0 @@ const dom = buildNode(content, updatedOptions.rootName, updatedOptions)[0];

@@ -9,5 +9,6 @@ "use strict";

function getCommonOptions(options) {
var _a;
return {
attributesGroupName: xml_common_js_1.XML_ATTRKEY,
textNodeName: options.xmlCharKey ?? xml_common_js_1.XML_CHARKEY,
textNodeName: (_a = options.xmlCharKey) !== null && _a !== void 0 ? _a : xml_common_js_1.XML_CHARKEY,
ignoreAttributes: false,

@@ -18,21 +19,7 @@ suppressBooleanAttributes: false,

function getSerializerOptions(options = {}) {
return {
...getCommonOptions(options),
attributeNamePrefix: "@_",
format: true,
suppressEmptyNode: true,
indentBy: "",
rootNodeName: options.rootName ?? "root",
cdataPropName: options.cdataPropName ?? "__cdata",
};
var _a, _b;
return Object.assign(Object.assign({}, getCommonOptions(options)), { attributeNamePrefix: "@_", format: true, suppressEmptyNode: true, indentBy: "", rootNodeName: (_a = options.rootName) !== null && _a !== void 0 ? _a : "root", cdataPropName: (_b = options.cdataPropName) !== null && _b !== void 0 ? _b : "__cdata" });
}
function getParserOptions(options = {}) {
return {
...getCommonOptions(options),
parseAttributeValue: false,
parseTagValue: false,
attributeNamePrefix: "",
stopNodes: options.stopNodes,
processEntities: true,
};
return Object.assign(Object.assign({}, getCommonOptions(options)), { parseAttributeValue: false, parseTagValue: false, attributeNamePrefix: "", stopNodes: options.stopNodes, processEntities: true });
}

@@ -77,3 +64,3 @@ /**

const value = parsedXml[key];
return typeof value === "object" ? { ...value } : value;
return typeof value === "object" ? Object.assign({}, value) : value;
}

@@ -80,0 +67,0 @@ }

@@ -6,5 +6,6 @@ // Copyright (c) Microsoft Corporation.

function getCommonOptions(options) {
var _a;
return {
attributesGroupName: XML_ATTRKEY,
textNodeName: options.xmlCharKey ?? XML_CHARKEY,
textNodeName: (_a = options.xmlCharKey) !== null && _a !== void 0 ? _a : XML_CHARKEY,
ignoreAttributes: false,

@@ -15,21 +16,7 @@ suppressBooleanAttributes: false,

function getSerializerOptions(options = {}) {
return {
...getCommonOptions(options),
attributeNamePrefix: "@_",
format: true,
suppressEmptyNode: true,
indentBy: "",
rootNodeName: options.rootName ?? "root",
cdataPropName: options.cdataPropName ?? "__cdata",
};
var _a, _b;
return Object.assign(Object.assign({}, getCommonOptions(options)), { attributeNamePrefix: "@_", format: true, suppressEmptyNode: true, indentBy: "", rootNodeName: (_a = options.rootName) !== null && _a !== void 0 ? _a : "root", cdataPropName: (_b = options.cdataPropName) !== null && _b !== void 0 ? _b : "__cdata" });
}
function getParserOptions(options = {}) {
return {
...getCommonOptions(options),
parseAttributeValue: false,
parseTagValue: false,
attributeNamePrefix: "",
stopNodes: options.stopNodes,
processEntities: true,
};
return Object.assign(Object.assign({}, getCommonOptions(options)), { parseAttributeValue: false, parseTagValue: false, attributeNamePrefix: "", stopNodes: options.stopNodes, processEntities: true });
}

@@ -73,3 +60,3 @@ /**

const value = parsedXml[key];
return typeof value === "object" ? { ...value } : value;
return typeof value === "object" ? Object.assign({}, value) : value;
}

@@ -76,0 +63,0 @@ }

@@ -6,5 +6,6 @@ // Copyright (c) Microsoft Corporation.

function getCommonOptions(options) {
var _a;
return {
attributesGroupName: XML_ATTRKEY,
textNodeName: options.xmlCharKey ?? XML_CHARKEY,
textNodeName: (_a = options.xmlCharKey) !== null && _a !== void 0 ? _a : XML_CHARKEY,
ignoreAttributes: false,

@@ -15,21 +16,7 @@ suppressBooleanAttributes: false,

function getSerializerOptions(options = {}) {
return {
...getCommonOptions(options),
attributeNamePrefix: "@_",
format: true,
suppressEmptyNode: true,
indentBy: "",
rootNodeName: options.rootName ?? "root",
cdataPropName: options.cdataPropName ?? "__cdata",
};
var _a, _b;
return Object.assign(Object.assign({}, getCommonOptions(options)), { attributeNamePrefix: "@_", format: true, suppressEmptyNode: true, indentBy: "", rootNodeName: (_a = options.rootName) !== null && _a !== void 0 ? _a : "root", cdataPropName: (_b = options.cdataPropName) !== null && _b !== void 0 ? _b : "__cdata" });
}
function getParserOptions(options = {}) {
return {
...getCommonOptions(options),
parseAttributeValue: false,
parseTagValue: false,
attributeNamePrefix: "",
stopNodes: options.stopNodes,
processEntities: true,
};
return Object.assign(Object.assign({}, getCommonOptions(options)), { parseAttributeValue: false, parseTagValue: false, attributeNamePrefix: "", stopNodes: options.stopNodes, processEntities: true });
}

@@ -73,3 +60,3 @@ /**

const value = parsedXml[key];
return typeof value === "object" ? { ...value } : value;
return typeof value === "object" ? Object.assign({}, value) : value;
}

@@ -76,0 +63,0 @@ }

{
"name": "@azure/core-xml",
"version": "1.4.2-alpha.20240322.2",
"version": "1.4.2-alpha.20240329.3",
"description": "Core library for interacting with XML payloads",

@@ -90,3 +90,3 @@ "sdk-type": "client",

"rimraf": "^5.0.5",
"tshy": "^1.11.1",
"tshy": "^1.13.0",
"typescript": "~5.3.3",

@@ -93,0 +93,0 @@ "vitest": "^1.3.1"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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