aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2017-05-08 11:30:07 -0700
committerJake Petroules <jake.petroules@qt.io>2017-05-09 16:51:34 +0000
commit2bde55de3926567daa58c9fd279c7e6022a5802f (patch)
treeaa20ed214ad188968a10463e591e8a36d5a201f3
parent0eb78ba6c43288a85d056fd6264bfb23c6202cfc (diff)
Fix Java manifest file parsing
This fixes several issues with the parser: - Empty lines (i.e. the customary trailing newline) would cause the parser to return an empty set of records. - Leading and trailing whitespace was not properly trimmed from each key and value. - An incorrectly formatted manifest file would silently return an empty set of records rather than throwing an exception. Change-Id: Ic3e8007268c3cef66d5472e998ac916cd86b44b3 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--share/qbs/modules/java/utils.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/share/qbs/modules/java/utils.js b/share/qbs/modules/java/utils.js
index f88a924f9..2add147d5 100644
--- a/share/qbs/modules/java/utils.js
+++ b/share/qbs/modules/java/utils.js
@@ -330,12 +330,14 @@ function manifestContents(filePath) {
if (contents) {
var dict = {};
- var lines = contents.split(/\r?\n/g);
+ var lines = contents.split(/\r?\n/g).filter(function (line) { return line.length > 0; });
for (var i in lines) {
var kv = lines[i].split(":");
if (kv.length !== 2)
- return undefined;
- dict[kv[0]] = kv[1];
+ throw new Error("Syntax error in manifest file '"
+ + filePath + "'; found \"" + lines[i] + "\" on line "
+ + parseInt(i, 10) + "; expected format \"Key: Value\"");
+ dict[kv[0].trim()] = kv[1].trim();
}
return dict;