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>2012-10-04 21:35:10 +0400
committerisaacs <i@izs.me>2012-10-04 21:35:10 +0400
commitd05e632b55f42a366ea62ac26c903546e05ab15b (patch)
tree0157678e6cb4933ab73a2618bae7532681b89c7a /node_modules/ini
parent237b95328ed6863c2e5efd370cc0940fd60b72f2 (diff)
ini@1.0.5
fix #2852
Diffstat (limited to 'node_modules/ini')
-rw-r--r--node_modules/ini/ini.js34
-rw-r--r--node_modules/ini/package.json4
-rw-r--r--node_modules/ini/test/fixtures/foo.ini3
-rw-r--r--node_modules/ini/test/foo.js4
4 files changed, 36 insertions, 9 deletions
diff --git a/node_modules/ini/ini.js b/node_modules/ini/ini.js
index 7939f20e5..45651c03f 100644
--- a/node_modules/ini/ini.js
+++ b/node_modules/ini/ini.js
@@ -56,10 +56,7 @@ function decode (str) {
, section = null
lines.forEach(function (line, _, __) {
- //line = line
- var rem = line.indexOf(";")
- if (rem !== -1) line = line.substr(0, rem)//.trim()
- if (!line) return
+ if (!line || line.match(/^\s*;/)) return
var match = line.match(re)
if (!match) return
if (match[1] !== undefined) {
@@ -108,13 +105,38 @@ function safe (val) {
|| (val.length > 1
&& val.charAt(0) === "\""
&& val.slice(-1) === "\"")
- || val !== val.trim() ) ? JSON.stringify(val) : val
+ || val !== val.trim() )
+ ? JSON.stringify(val)
+ : val.replace(/;/g, '\\;')
}
-function unsafe (val) {
+function unsafe (val, doUnesc) {
val = (val || "").trim()
if (val.charAt(0) === "\"" && val.slice(-1) === "\"") {
try { val = JSON.parse(val) } catch (_) {}
+ } else {
+ // walk the val to find the first not-escaped ; character
+ var esc = false
+ var unesc = "";
+ for (var i = 0, l = val.length; i < l; i++) {
+ var c = val.charAt(i)
+ if (esc) {
+ if (c === "\\" || c === ";")
+ unesc += c
+ else
+ unesc += "\\" + c
+ esc = false
+ } else if (c === ";") {
+ break
+ } else if (c === "\\") {
+ esc = true
+ } else {
+ unesc += c
+ }
+ }
+ if (esc)
+ unesc += "\\"
+ return unesc
}
return val
}
diff --git a/node_modules/ini/package.json b/node_modules/ini/package.json
index 1ab148897..3f45c18e2 100644
--- a/node_modules/ini/package.json
+++ b/node_modules/ini/package.json
@@ -6,7 +6,7 @@
},
"name": "ini",
"description": "An ini encoder/decoder for node",
- "version": "1.0.4",
+ "version": "1.0.5",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/ini.git"
@@ -23,6 +23,6 @@
"tap": "~0.0.9"
},
"readme": "An ini format parser and serializer for node.\n\nSections are treated as nested objects. Items before the first heading\nare saved on the object directly.\n\n## Usage\n\nConsider an ini-file `config.ini` that looks like this:\n\n ; this comment is being ignored\n scope = global\n\n [database]\n user = dbuser\n password = dbpassword\n database = use_this_database\n\n [paths.default]\n datadir = /var/lib/data\n\nYou can read, manipulate and write the ini-file like so:\n\n var fs = require('fs')\n , ini = require('ini')\n\n var config = ini.parse(fs.readFileSync('./config.ini', 'utf-8'))\n\n config.scope = 'local'\n config.database.database = 'use_another_database'\n config.paths.default.tmpdir = '/tmp'\n delete config.paths.default.datadir\n\n fs.writeFileSync('./config_modified.ini', ini.stringify(config, 'section'))\n\nThis will result in a file called `config_modified.ini` being written to the filesystem with the following content:\n\n [section]\n scope = local\n [section.database]\n user = dbuser\n password = dbpassword\n database = use_another_database\n [section.paths.default]\n tmpdir = /tmp\n\n## API\n\n### decode(inistring)\nDecode the ini-style formatted `inistring` into a nested object.\n\n### parse(inistring)\nAlias for `decode(inistring)`\n\n### encode(object, [section])\nEncode the object `object` into an ini-style formatted string. If the optional parameter `section` is given, then all top-level properties of the object are put into this section and the `section`-string is prepended to all sub-sections, see the usage example above.\n\n### stringify(object, [section])\nAlias for `encode(object, [section])`\n\n### safe(val)\nEscapes the string `val` such that it is safe to be used as a key or value in an ini-file. Basically escapes quotes. For example\n\n ini.safe('\"unsafe string\"')\n\nwould result in\n\n \"\\\"unsafe string\\\"\"\n\n### unsafe(val)\nUnescapes the string `val`\n\n",
- "_id": "ini@1.0.4",
+ "_id": "ini@1.0.5",
"_from": "ini@latest"
}
diff --git a/node_modules/ini/test/fixtures/foo.ini b/node_modules/ini/test/fixtures/foo.ini
index e5b186604..6f11f3679 100644
--- a/node_modules/ini/test/fixtures/foo.ini
+++ b/node_modules/ini/test/fixtures/foo.ini
@@ -27,3 +27,6 @@ x.y.z = xyz
[x\.y\.z.a\.b\.c]
a.b.c = abc
+
+; this next one is not a comment! it's escaped!
+nocomment = this\; this is not a comment
diff --git a/node_modules/ini/test/foo.js b/node_modules/ini/test/foo.js
index 2b32bb62f..64bd22329 100644
--- a/node_modules/ini/test/foo.js
+++ b/node_modules/ini/test/foo.js
@@ -21,6 +21,7 @@ var i = require("../")
+ 'j = 2\n\n[x\\.y\\.z]\nx.y.z = xyz\n\n'
+ '[x\\.y\\.z.a\\.b\\.c]\n'
+ 'a.b.c = abc\n'
+ + 'nocomment = this\\; this is not a comment\n'
, expectD =
{ o: 'p',
'a with spaces': 'b c',
@@ -35,7 +36,8 @@ var i = require("../")
'x.y.z': {
'x.y.z': 'xyz',
'a.b.c': {
- 'a.b.c': 'abc'
+ 'a.b.c': 'abc',
+ 'nocomment': 'this\; this is not a comment'
}
}
}