Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: node_modules/vulcanize/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/rc/node_modules/ini/ini.js

Issue 877193002: Upgrade vulcanize to 0.7.6. (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: node_modules/vulcanize/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/rc/node_modules/ini/ini.js
diff --git a/node_modules/vulcanize/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/rc/node_modules/ini/ini.js b/node_modules/vulcanize/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/rc/node_modules/ini/ini.js
index eaf32093317345a05ea3c268620caaff924d8c5c..1e232e74387036a057fb58441c5ac4fc957343f4 100644
--- a/node_modules/vulcanize/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/rc/node_modules/ini/ini.js
+++ b/node_modules/vulcanize/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/rc/node_modules/ini/ini.js
@@ -7,31 +7,47 @@ exports.unsafe = unsafe
var eol = process.platform === "win32" ? "\r\n" : "\n"
-function encode (obj, section) {
+function encode (obj, opt) {
var children = []
, out = ""
+ if (typeof opt === "string") {
+ opt = {
+ section: opt,
+ whitespace: false
+ }
+ } else {
+ opt = opt || {}
+ opt.whitespace = opt.whitespace === true
+ }
+
+ var separator = opt.whitespace ? " = " : "="
+
Object.keys(obj).forEach(function (k, _, __) {
var val = obj[k]
if (val && Array.isArray(val)) {
val.forEach(function(item) {
- out += safe(k + "[]") + " = " + safe(item) + "\n"
+ out += safe(k + "[]") + separator + safe(item) + "\n"
})
}
else if (val && typeof val === "object") {
children.push(k)
} else {
- out += safe(k) + " = " + safe(val) + eol
+ out += safe(k) + separator + safe(val) + eol
}
})
- if (section && out.length) {
- out = "[" + safe(section) + "]" + eol + out
+ if (opt.section && out.length) {
+ out = "[" + safe(opt.section) + "]" + eol + out
}
children.forEach(function (k, _, __) {
var nk = dotSplit(k).join('\\.')
- var child = encode(obj[k], (section ? section + "." : "") + nk)
+ var section = (opt.section ? opt.section + "." : "") + nk
+ var child = encode(obj[k], {
+ section: section,
+ whitespace: opt.whitespace
+ })
if (out.length && child.length) {
out += eol
}
@@ -42,12 +58,12 @@ function encode (obj, section) {
}
function dotSplit (str) {
- return str.replace(/\1/g, '\2LITERAL\\1LITERAL\2')
- .replace(/\\\./g, '\1')
+ return str.replace(/\1/g, '\u0002LITERAL\\1LITERAL\u0002')
+ .replace(/\\\./g, '\u0001')
.split(/\./).map(function (part) {
return part.replace(/\1/g, '\\.')
- .replace(/\2LITERAL\\1LITERAL\2/g, '\1')
- })
+ .replace(/\2LITERAL\\1LITERAL\2/g, '\u0001')
+ })
}
function decode (str) {
@@ -61,7 +77,7 @@ function decode (str) {
, section = null
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[1] !== undefined) {
@@ -122,21 +138,29 @@ function decode (str) {
return out
}
+function isQuoted (val) {
+ return (val.charAt(0) === "\"" && val.slice(-1) === "\"")
+ || (val.charAt(0) === "'" && val.slice(-1) === "'")
+}
+
function safe (val) {
return ( typeof val !== "string"
|| val.match(/[\r\n]/)
|| val.match(/^\[/)
|| (val.length > 1
- && val.charAt(0) === "\""
- && val.slice(-1) === "\"")
+ && isQuoted(val))
|| val !== val.trim() )
? JSON.stringify(val)
- : val.replace(/;/g, '\\;')
+ : val.replace(/;/g, '\\;').replace(/#/g, "\\#")
}
function unsafe (val, doUnesc) {
val = (val || "").trim()
- if (val.charAt(0) === "\"" && val.slice(-1) === "\"") {
+ if (isQuoted(val)) {
+ // remove the single quotes before calling JSON.parse
+ if (val.charAt(0) === "'") {
+ val = val.substr(1, val.length - 2);
+ }
try { val = JSON.parse(val) } catch (_) {}
} else {
// walk the val to find the first not-escaped ; character
@@ -145,12 +169,12 @@ function unsafe (val, doUnesc) {
for (var i = 0, l = val.length; i < l; i++) {
var c = val.charAt(i)
if (esc) {
- if (c === "\\" || c === ";")
+ if ("\\;#".indexOf(c) !== -1)
unesc += c
else
unesc += "\\" + c
esc = false
- } else if (c === ";") {
+ } else if (";#".indexOf(c) !== -1) {
break
} else if (c === "\\") {
esc = true

Powered by Google App Engine
This is Rietveld 408576698