Permalink
Browse files

v1.1.3

  • Loading branch information...
1 parent 23bec99 commit 19f4d41efe0080ec34ac6dbaf7c1c9cad13d54ae Gabriel Llamas committed Dec 7, 2013
Showing with 30 additions and 7 deletions.
  1. +3 −0 CHANGES
  2. +15 −6 lib/read.js
  3. +1 −1 package.json
  4. +11 −0 test/parse.js
View
@@ -1,3 +1,6 @@
+v1.1.3 (07 Dec 2013)
+ When a namespace chain is invalid it now returns an error.
+
v1.1.2 (22 Oct 2013)
Bugfix stringifying characters when "unicode" was true (improved ISO 8859-1
compatibility).
View
@@ -107,6 +107,9 @@ var namespace = function (p, key, value){
str = n[i];
if (p[str] === undefined){
p[str] = {};
+ }else if (typeof p[str] !== "object"){
+ return new Error ("Invalid namespace, the key must contain an " +
+ "object: " + str);
}
p = p[str];
}
@@ -205,6 +208,8 @@ var build = function (data, options, dirname, cb){
//then the var "a.b" searches for "a.b"
var line;
+ var error;
+
if (options.reviver){
if (options.sections){
line = function (key, value){
@@ -220,8 +225,9 @@ var build = function (data, options, dirname, cb){
else o[currentSection][key] = value;
if (options.namespaces){
- namespace (currentSection === null ? n : n[currentSection], key,
- value);
+ error = namespace (currentSection === null ? n : n[currentSection],
+ key, value);
+ if (error) abort (error);
}
}
};
@@ -238,7 +244,8 @@ var build = function (data, options, dirname, cb){
o[key] = value;
if (options.namespaces){
- namespace (n, key, value);
+ error = namespace (n, key, value);
+ if (error) abort (error);
}
}
};
@@ -252,8 +259,9 @@ var build = function (data, options, dirname, cb){
else o[currentSection][key] = value;
if (options.namespaces){
- namespace (currentSection === null ? n : n[currentSection], key,
- value);
+ error = namespace (currentSection === null ? n : n[currentSection],
+ key, value);
+ if (error) abort (error);
}
};
}else{
@@ -263,7 +271,8 @@ var build = function (data, options, dirname, cb){
o[key] = value;
if (options.namespaces){
- namespace (n, key, value);
+ error = namespace (n, key, value);
+ if (error) abort (error);
}
};
}
View
@@ -1,6 +1,6 @@
{
"name": "properties",
- "version": "1.1.2",
+ "version": "1.1.3",
"description": ".properties parser/stringifier",
"keywords": ["properties", "ini", "parser", "stringifier", "config"],
"author": "Gabriel Llamas <gagle@outlook.com>",
View
@@ -433,6 +433,17 @@ var tests = {
done ();
});
},
+ "namespaces (invalid)": function (done){
+ var options = {
+ namespaces: true
+ };
+
+ properties.parse ("a=1\na.b=2", options, function (error, p){
+ assert.ok (error);
+
+ done ();
+ });
+ },
"include": function (done){
var options = { path: true, include: true };

0 comments on commit 19f4d41

Please sign in to comment.