Socket
Socket
Sign inDemoInstall

xmlbuilder

Package Overview
Dependencies
Maintainers
0
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xmlbuilder - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

10

lib/XMLBuilder.js

@@ -32,3 +32,3 @@ (function() {

xmldec.version = '' + xmldec.version || '';
if (!xmldec.version.match(this.val.VersionNum)) {
if (!xmldec.version.match(/1\.[0-9]+/)) {
throw new Error("Invalid version number: " + xmldec.version);

@@ -41,3 +41,3 @@ }

xmldec.encoding = '' + xmldec.encoding || '';
if (!xmldec.encoding.match(this.val.EncName)) {
if (!xmldec.encoding.match(/[A-Za-z](?:[A-Za-z0-9._-]|-)*/)) {
throw new Error("Invalid encoding: " + xmldec.encoding);

@@ -55,5 +55,2 @@ }

doctype.name = '' + doctype.name || '';
if (!String(doctype.name).match("^" + this.val.Name + "$")) {
throw new Error("Invalid document name: " + doctype.name);
}
att = {

@@ -64,5 +61,2 @@ name: doctype.name

doctype.ext = '' + doctype.ext || '';
if (!String(doctype.ext).match("^" + this.val.ExternalID + "$")) {
throw new Error("Invalid external ID: " + doctype.ext);
}
att.ext = doctype.ext;

@@ -69,0 +63,0 @@ }

83

lib/XMLFragment.js

@@ -18,2 +18,3 @@ (function() {

name = '' + name || '';
this.assertLegalChar(name);
attributes != null ? attributes : attributes = {};

@@ -23,7 +24,5 @@ for (key in attributes) {

val = attributes[key];
val = '' + val || '';
attributes[key] = this.escape(val);
}
if (!name.match("^" + this.val.Name + "$")) {
throw new Error("Invalid element name: " + name);
}
child = new XMLFragment(this, name, attributes);

@@ -40,5 +39,3 @@ this.children.push(child);

value = this.escape(value);
if (!value.match(this.val.CharData)) {
throw new Error("Invalid element text: " + value);
}
this.assertLegalChar(value);
child = new XMLFragment(this, '', {}, value);

@@ -54,3 +51,4 @@ this.children.push(child);

value = '' + value || '';
if (!value.match(this.val.CDATA)) {
this.assertLegalChar(value);
if (value.match(/]]>/)) {
throw new Error("Invalid CDATA text: " + value);

@@ -69,4 +67,5 @@ }

value = this.escape(value);
if (!value.match("^" + this.val.CommentContent + "$")) {
throw new Error("Invalid comment text: " + value);
this.assertLegalChar(value);
if (value.match(/--/)) {
throw new Error("Comment text cannot contain double-hypen: " + value);
}

@@ -77,2 +76,12 @@ child = new XMLFragment(this, '', {}, '<!-- ' + value + ' -->');

};
XMLFragment.prototype.raw = function(value) {
var child;
if (!(value != null)) {
throw new Error("Missing raw text");
}
value = '' + value || '';
child = new XMLFragment(this, '', {}, value);
this.children.push(child);
return this;
};
XMLFragment.prototype.up = function() {

@@ -85,2 +94,3 @@ if (!(this.parent != null)) {

XMLFragment.prototype.attribute = function(name, value) {
var _ref;
if (!(name != null)) {

@@ -94,10 +104,7 @@ throw new Error("Missing attribute name");

value = '' + value || '';
value = this.escape(value);
if (!name.match("^" + this.val.Name + "$")) {
throw new Error("Invalid attribute name: " + name);
(_ref = this.attributes) != null ? _ref : this.attributes = {};
if (this.attributes.hasOwnProperty(name)) {
throw new Error("Attribute already defined: " + name);
}
if (!value.match("^" + this.val.AttValue + "$")) {
throw new Error("Invalid attribute value: " + value);
}
this.attributes[name] = value;
this.attributes[name] = this.escape(value);
return this;

@@ -160,2 +167,10 @@ };

};
XMLFragment.prototype.assertLegalChar = function(str) {
var chars, chr;
chars = /[\u0000-\u0008\u000B-\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE-\uFFFF]/;
chr = str.match(chars);
if (chr) {
throw new Error("Invalid character (" + chr + ") in string: " + str);
}
};
XMLFragment.prototype.ele = function(name, attributes) {

@@ -173,4 +188,4 @@ return this.element(name, attributes);

};
XMLFragment.prototype.com = function(name, value) {
return this.comment(name, value);
XMLFragment.prototype.com = function(value) {
return this.comment(value);
};

@@ -189,5 +204,8 @@ XMLFragment.prototype.e = function(name, attributes) {

};
XMLFragment.prototype.c = function(name, value) {
return this.comment(name, value);
XMLFragment.prototype.c = function(value) {
return this.comment(value);
};
XMLFragment.prototype.r = function(value) {
return this.raw(value);
};
XMLFragment.prototype.u = function() {

@@ -198,28 +216,3 @@ return this.up;

})();
XMLFragment.prototype.val = {};
XMLFragment.prototype.val.Space = "(?:\u0020|\u0009|\u000D|\u000A)+";
XMLFragment.prototype.val.Char = "\u0009|\u000A|\u000D|[\u0020-\uD7FF]|[\uE000-\uFFFD]";
XMLFragment.prototype.val.NameStartChar = ":|[A-Z]|_|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|" + "[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|" + "[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]";
XMLFragment.prototype.val.NameChar = XMLFragment.prototype.val.NameStartChar + '|' + "-|\.|[0-9]|\u00B7|[\u0300-\u036F]|[\u203F-\u2040]";
XMLFragment.prototype.val.CharRef = "&#[0-9]+;|&#x[0-9a-fA-F]+;";
XMLFragment.prototype.val.Name = '(?:' + XMLFragment.prototype.val.NameStartChar + ')' + '(?:' + XMLFragment.prototype.val.NameChar + ')*';
XMLFragment.prototype.val.NMToken = '(?:' + XMLFragment.prototype.val.NameChar + ')+';
XMLFragment.prototype.val.EntityRef = '&' + XMLFragment.prototype.val.Name + ';';
XMLFragment.prototype.val.Reference = '&' + XMLFragment.prototype.val.Name + ';' + '|' + XMLFragment.prototype.val.CharRef;
XMLFragment.prototype.val.PEReference = '%' + XMLFragment.prototype.val.Name + ';';
XMLFragment.prototype.val.EntityValue = '(?:[^%&"]|%' + XMLFragment.prototype.val.Name + ';|&' + XMLFragment.prototype.val.Name + ';)*';
XMLFragment.prototype.val.AttValue = '(?:[^<&"]|' + XMLFragment.prototype.val.Reference + ')*';
XMLFragment.prototype.val.SystemLiteral = '[^"]*';
XMLFragment.prototype.val.PubIDChar = "\u0020|\u000D|\u000A|[a-zA-Z0-9]|[-'()+,./:=?;!*#@$_%]";
XMLFragment.prototype.val.PubIDLiteral = '(?:' + XMLFragment.prototype.val.PubIDChar + ')*';
XMLFragment.prototype.val.CommentChar = '(?!-)' + '(?:' + XMLFragment.prototype.val.Char + ')';
XMLFragment.prototype.val.CommentContent = '(?:' + XMLFragment.prototype.val.CommentChar + '|' + '-' + XMLFragment.prototype.val.CommentChar + ')*';
XMLFragment.prototype.val.Comment = '<!--' + XMLFragment.prototype.val.CommentContent + '-->';
XMLFragment.prototype.val.ExternalID = '(?:' + 'SYSTEM' + XMLFragment.prototype.val.Space + XMLFragment.prototype.val.SystemLiteral + ')|';
'(?:' + 'PUBLIC' + XMLFragment.prototype.val.Space + XMLFragment.prototype.val.PubIDLateral + XMLFragment.prototype.val.Space + XMLFragment.prototype.val.SystemLiteral + ')';
XMLFragment.prototype.val.CharData = /^(?![^<&]*]]>[^<&]*)[^<&]*$/;
XMLFragment.prototype.val.CDATA = /^(?:(?!]]>).)*$/;
XMLFragment.prototype.val.VersionNum = /^1\.[0-9]+$/;
XMLFragment.prototype.val.EncName = /^[A-Za-z](?:[A-Za-z0-9\._]|-)*$/;
module.exports = XMLFragment;
}).call(this);
{
"name" : "xmlbuilder",
"version": "0.1.0",
"version": "0.1.1",
"description": "An XML builder for node.js",

@@ -5,0 +5,0 @@ "author": "Ozgur Ozcitak <oozcitak@gmail.com>",

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