From 7604a9809472ea90da08df86a4509d755c5d5762 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 11 Dec 2020 11:40:41 -0800 Subject: [PATCH] ini@1.3.7 --- node_modules/ini/ini.js | 90 ++++++++++++++++++----------------- node_modules/ini/package.json | 21 ++++---- package-lock.json | 22 ++++----- package.json | 2 +- 4 files changed, 69 insertions(+), 66 deletions(-) diff --git a/node_modules/ini/ini.js b/node_modules/ini/ini.js index 040125886aa94..f8107ca52d8c1 100644 --- a/node_modules/ini/ini.js +++ b/node_modules/ini/ini.js @@ -15,10 +15,10 @@ function encode (obj, opt) { if (typeof opt === 'string') { opt = { section: opt, - whitespace: false + whitespace: false, } } else { - opt = opt || {} + opt = opt || Object.create(null) opt.whitespace = opt.whitespace === true } @@ -30,27 +30,25 @@ function encode (obj, opt) { val.forEach(function (item) { out += safe(k + '[]') + separator + safe(item) + '\n' }) - } else if (val && typeof val === 'object') { + } else if (val && typeof val === 'object') children.push(k) - } else { + else out += safe(k) + separator + safe(val) + eol - } }) - if (opt.section && out.length) { + if (opt.section && out.length) out = '[' + safe(opt.section) + ']' + eol + out - } children.forEach(function (k, _, __) { var nk = dotSplit(k).join('\\.') var section = (opt.section ? opt.section + '.' : '') + nk var child = encode(obj[k], { section: section, - whitespace: opt.whitespace + whitespace: opt.whitespace, }) - if (out.length && child.length) { + if (out.length && child.length) out += eol - } + out += child }) @@ -62,12 +60,12 @@ function dotSplit (str) { .replace(/\\\./g, '\u0001') .split(/\./).map(function (part) { return part.replace(/\1/g, '\\.') - .replace(/\2LITERAL\\1LITERAL\2/g, '\u0001') + .replace(/\2LITERAL\\1LITERAL\2/g, '\u0001') }) } function decode (str) { - var out = {} + var out = Object.create(null) var p = out var section = null // section |key = value @@ -75,21 +73,25 @@ function decode (str) { var lines = str.split(/[\r\n]+/g) lines.forEach(function (line, _, __) { - if (!line || line.match(/^\s*[;#]/)) return + if (!line || line.match(/^\s*[;#]/)) + return var match = line.match(re) - if (!match) return + if (!match) + return if (match[1] !== undefined) { section = unsafe(match[1]) if (section === '__proto__') { // not allowed // keep parsing the section, but don't attach it. - p = {} + p = Object.create(null) return } - p = out[section] = out[section] || {} + p = out[section] = out[section] || Object.create(null) return } var key = unsafe(match[2]) + if (key === '__proto__') + return var value = match[3] ? unsafe(match[4]) : true switch (value) { case 'true': @@ -100,21 +102,20 @@ function decode (str) { // Convert keys with '[]' suffix to an array if (key.length > 2 && key.slice(-2) === '[]') { key = key.substring(0, key.length - 2) - if (key === '__proto__') return - if (!p[key]) { + if (key === '__proto__') + return + if (!p[key]) p[key] = [] - } else if (!Array.isArray(p[key])) { + else if (!Array.isArray(p[key])) p[key] = [p[key]] - } } // safeguard against resetting a previously defined // array by accidentally forgetting the brackets - if (Array.isArray(p[key])) { + if (Array.isArray(p[key])) p[key].push(value) - } else { + else p[key] = value - } }) // {a:{y:1},"a.b":{x:2}} --> {a:{y:1,b:{x:2}}} @@ -122,9 +123,9 @@ function decode (str) { Object.keys(out).filter(function (k, _, __) { if (!out[k] || typeof out[k] !== 'object' || - Array.isArray(out[k])) { + Array.isArray(out[k])) return false - } + // see if the parent section is also an object. // if so, add it to that, and mark this one for deletion var parts = dotSplit(k) @@ -132,13 +133,15 @@ function decode (str) { var l = parts.pop() var nl = l.replace(/\\\./g, '.') parts.forEach(function (part, _, __) { - if (part === '__proto__') return - if (!p[part] || typeof p[part] !== 'object') p[part] = {} + if (part === '__proto__') + return + if (!p[part] || typeof p[part] !== 'object') + p[part] = Object.create(null) p = p[part] }) - if (p === out && nl === l) { + if (p === out && nl === l) return false - } + p[nl] = out[k] return true }).forEach(function (del, _, __) { @@ -160,18 +163,20 @@ function safe (val) { (val.length > 1 && isQuoted(val)) || val !== val.trim()) - ? JSON.stringify(val) - : val.replace(/;/g, '\\;').replace(/#/g, '\\#') + ? JSON.stringify(val) + : val.replace(/;/g, '\\;').replace(/#/g, '\\#') } function unsafe (val, doUnesc) { val = (val || '').trim() if (isQuoted(val)) { // remove the single quotes before calling JSON.parse - if (val.charAt(0) === "'") { + if (val.charAt(0) === "'") val = val.substr(1, val.length - 2) - } - try { val = JSON.parse(val) } catch (_) {} + + try { + val = JSON.parse(val) + } catch (_) {} } else { // walk the val to find the first not-escaped ; character var esc = false @@ -179,23 +184,22 @@ function unsafe (val, doUnesc) { for (var i = 0, l = val.length; i < l; i++) { var c = val.charAt(i) if (esc) { - if ('\\;#'.indexOf(c) !== -1) { + if ('\\;#'.indexOf(c) !== -1) unesc += c - } else { + else unesc += '\\' + c - } + esc = false - } else if (';#'.indexOf(c) !== -1) { + } else if (';#'.indexOf(c) !== -1) break - } else if (c === '\\') { + else if (c === '\\') esc = true - } else { + else unesc += c - } } - if (esc) { + if (esc) unesc += '\\' - } + return unesc.trim() } return val diff --git a/node_modules/ini/package.json b/node_modules/ini/package.json index c23bc875dd12e..f9b30622985b2 100644 --- a/node_modules/ini/package.json +++ b/node_modules/ini/package.json @@ -2,26 +2,29 @@ "author": "Isaac Z. Schlueter (http://blog.izs.me/)", "name": "ini", "description": "An ini encoder/decoder for node", - "version": "1.3.6", + "version": "1.3.7", "repository": { "type": "git", "url": "git://github.com/isaacs/ini.git" }, "main": "ini.js", "scripts": { - "pretest": "standard ini.js", - "test": "tap test/*.js --100 -J", + "eslint": "eslint", + "lint": "npm run eslint -- ini.js test/*.js", + "lintfix": "npm run lint -- --fix", + "test": "tap", + "posttest": "npm run lint", "preversion": "npm test", "postversion": "npm publish", "prepublishOnly": "git push origin --follow-tags" }, - "engines": { - "node": "*" - }, - "dependencies": {}, "devDependencies": { - "standard": "^10.0.3", - "tap": "^10.7.3 || 11" + "eslint": "^7.9.0", + "eslint-plugin-import": "^2.22.0", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-standard": "^4.0.1", + "tap": "14" }, "license": "ISC", "files": [ diff --git a/package-lock.json b/package-lock.json index 91508cab7f1f5..6e6b83146a23a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -69,6 +69,7 @@ "tar", "text-table", "tiny-relative-date", + "treeverse", "uuid", "validate-npm-package-name", "which", @@ -333,7 +334,6 @@ "strip-json-comments", "supports-color", "table", - "treeverse", "tsconfig-paths", "tunnel-agent", "tweetnacl", @@ -354,7 +354,6 @@ "wrappy", "yallist" ], - "hasInstallScript": true, "license": "Artistic-2.0", "dependencies": { "@npmcli/arborist": "^2.0.0", @@ -377,7 +376,7 @@ "glob": "^7.1.4", "graceful-fs": "^4.2.3", "hosted-git-info": "^3.0.6", - "ini": "^1.3.6", + "ini": "^1.3.7", "init-package-json": "^2.0.1", "is-cidr": "^4.0.2", "leven": "^3.1.0", @@ -3549,13 +3548,10 @@ "inBundle": true }, "node_modules/ini": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.6.tgz", - "integrity": "sha512-IZUoxEjNjubzrmvzZU4lKP7OnYmX72XRl3sqkfJhBKweKi5rnGi5+IUdlj/H1M+Ip5JQ1WzaDMOBRY90Ajc5jg==", - "inBundle": true, - "engines": { - "node": "*" - } + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.7.tgz", + "integrity": "sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==", + "inBundle": true }, "node_modules/init-package-json": { "version": "2.0.1", @@ -11980,9 +11976,9 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "ini": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.6.tgz", - "integrity": "sha512-IZUoxEjNjubzrmvzZU4lKP7OnYmX72XRl3sqkfJhBKweKi5rnGi5+IUdlj/H1M+Ip5JQ1WzaDMOBRY90Ajc5jg==" + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.7.tgz", + "integrity": "sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ==" }, "init-package-json": { "version": "2.0.1", diff --git a/package.json b/package.json index a065d64fc8e88..ccc8e459121e6 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "glob": "^7.1.4", "graceful-fs": "^4.2.3", "hosted-git-info": "^3.0.6", - "ini": "^1.3.6", + "ini": "^1.3.7", "init-package-json": "^2.0.1", "is-cidr": "^4.0.2", "leven": "^3.1.0",