summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/ini/ini.js
diff options
context:
space:
mode:
authorTimothy J Fontaine <tjfontaine@gmail.com>2014-06-05 15:18:15 -0700
committerTimothy J Fontaine <tjfontaine@gmail.com>2014-06-06 15:07:29 -0700
commitf051f317905b3b31945dfe965a492e54902e595f (patch)
tree06fedaefc3fc2dd5d6f197762afa4cd351659858 /deps/npm/node_modules/ini/ini.js
parent535c7777ac674ba86cf93c44824e07b0e23ea8c4 (diff)
downloadnode-new-f051f317905b3b31945dfe965a492e54902e595f.tar.gz
npm: upgrade to v1.4.14
Diffstat (limited to 'deps/npm/node_modules/ini/ini.js')
-rw-r--r--deps/npm/node_modules/ini/ini.js30
1 files changed, 19 insertions, 11 deletions
diff --git a/deps/npm/node_modules/ini/ini.js b/deps/npm/node_modules/ini/ini.js
index eaf3209331..1d1e6e9341 100644
--- a/deps/npm/node_modules/ini/ini.js
+++ b/deps/npm/node_modules/ini/ini.js
@@ -42,12 +42,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 +61,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 +122,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 +153,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