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

xmlbuilder2

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xmlbuilder2 - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

5

CHANGELOG.md

@@ -5,2 +5,7 @@ # Change Log

## [2.1.0] - 2020-03-31
### Features
- Added the `noDoubleEncoding` option to prevent html entities from being re-encoded when serialized (See [#15](https://github.com/oozcitak/xmlbuilder2/issues/15)).
## [2.0.0] - 2020-03-30

@@ -7,0 +12,0 @@

70

lib/builder/XMLBuilderCBImpl.js

@@ -153,15 +153,23 @@ "use strict";

}
let result = "";
for (let i = 0; i < node.data.length; i++) {
const c = node.data[i];
if (c === "&")
result += "&amp;";
else if (c === "<")
result += "&lt;";
else if (c === ">")
result += "&gt;";
else
result += c;
let markup = "";
if (this._options.noDoubleEncoding) {
markup = node.data.replace(/(?!&\S+;)&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/\r/g, '&#xD;');
}
this._push(this._writer.text(result));
else {
for (let i = 0; i < node.data.length; i++) {
const c = node.data[i];
if (c === "&")
markup += "&amp;";
else if (c === "<")
markup += "&lt;";
else if (c === ">")
markup += "&gt;";
else
markup += c;
}
}
this._push(this._writer.text(markup));
return this;

@@ -565,17 +573,27 @@ }

return "";
let result = "";
for (let i = 0; i < value.length; i++) {
const c = value[i];
if (c === "\"")
result += "&quot;";
else if (c === "&")
result += "&amp;";
else if (c === "<")
result += "&lt;";
else if (c === ">")
result += "&gt;";
else
result += c;
if (this._options.noDoubleEncoding) {
return value.replace(/(?!&\S+;)&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/"/g, '&quot;')
.replace(/\t/g, '&#x9;')
.replace(/\n/g, '&#xA;')
.replace(/\r/g, '&#xD;');
}
return result;
else {
let result = "";
for (let i = 0; i < value.length; i++) {
const c = value[i];
if (c === "\"")
result += "&quot;";
else if (c === "&")
result += "&amp;";
else if (c === "<")
result += "&lt;";
else if (c === ">")
result += "&gt;";
else
result += c;
}
return result;
}
}

@@ -582,0 +600,0 @@ /**

@@ -91,3 +91,3 @@ import { Node, Document } from "@oozcitak/dom/lib/dom/interfaces";

* - char - the invalid character to be replaced
* - offset - the offset of invalid character
* - offset - the offset of the invalid character
* - str - the input string

@@ -261,2 +261,6 @@ */

wellFormed?: boolean;
/**
* Prevents existing html entities from being re-encoded. Defaults to `false`.
*/
noDoubleEncoding?: boolean;
};

@@ -1051,2 +1055,6 @@ /**

wellFormed: boolean;
/**
* Prevents existing html entities from being re-encoded. Defaults to `false.
*/
noDoubleEncoding: boolean;
};

@@ -1053,0 +1061,0 @@ /**

@@ -120,3 +120,3 @@ import { BaseWriterOptions, XMLBuilderOptions, XMLSerializedValue } from "../interfaces";

*/
serializeNode(node: Node, requireWellFormed: boolean): void;
serializeNode(node: Node, requireWellFormed: boolean, noDoubleEncoding: boolean): void;
/**

@@ -123,0 +123,0 @@ * Produces an XML serialization of a node.

@@ -20,2 +20,3 @@ "use strict";

wellFormed: false,
noDoubleEncoding: false,
prettyPrint: false,

@@ -29,3 +30,5 @@ indent: ' ',

const objectWriterOptions = util_1.applyDefaults(options, {
format: "object"
format: "object",
wellFormed: false,
noDoubleEncoding: false,
});

@@ -32,0 +35,0 @@ const objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions);

@@ -20,2 +20,3 @@ "use strict";

wellFormed: false,
noDoubleEncoding: false,
group: false

@@ -26,3 +27,4 @@ });

format: "object",
wellFormed: false
wellFormed: false,
noDoubleEncoding: false
});

@@ -29,0 +31,0 @@ const objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions);

@@ -20,2 +20,3 @@ "use strict";

wellFormed: false,
noDoubleEncoding: false,
group: false

@@ -45,3 +46,3 @@ });

*/
this.serializeNode(node, options.wellFormed);
this.serializeNode(node, options.wellFormed, options.noDoubleEncoding);
/**

@@ -48,0 +49,0 @@ * Second pass, process node lists. Above example becomes:

@@ -26,2 +26,3 @@ "use strict";

wellFormed: false,
noDoubleEncoding: false,
headless: false,

@@ -52,3 +53,3 @@ prettyPrint: false,

}
this.serializeNode(node, this._options.wellFormed);
this.serializeNode(node, this._options.wellFormed, this._options.noDoubleEncoding);
// remove trailing newline

@@ -55,0 +56,0 @@ if (this._options.prettyPrint &&

{
"name": "xmlbuilder2",
"version": "2.0.0",
"version": "2.1.0",
"keywords": [

@@ -5,0 +5,0 @@ "xml",

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 too big to display

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

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