Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2014-05-20 02:20:47 +0400
committerisaacs <i@izs.me>2014-05-20 02:21:35 +0400
commit015af8f0c42c1fd87e6521130e645b73f4559ddb (patch)
tree15b19402be0fdf3fc3f09969d238a3abe881dc36 /node_modules/ini/ini.js
parent69bc6b5f01242b29527042bc5280087657fd6784 (diff)
Bump many minor dep versions
abbrev columnify fstream-npm glob ini minimatch npmconf
Diffstat (limited to 'node_modules/ini/ini.js')
-rw-r--r--node_modules/ini/ini.js30
1 files changed, 19 insertions, 11 deletions
diff --git a/node_modules/ini/ini.js b/node_modules/ini/ini.js
index eaf320933..1d1e6e934 100644
--- a/node_modules/ini/ini.js
+++ b/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