Skip to content

Commit fc7fa45

Browse files
trufaeradare
authored andcommitted
Be more strict when parsing plists
1 parent d48c5a0 commit fc7fa45

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Diff for: lib/parse.js

+2
Original file line numberDiff line numberDiff line change
@@ -217,5 +217,7 @@ function parsePlistXML (node) {
217217

218218
} else if (node.nodeName === 'false') {
219219
return false;
220+
} else {
221+
throw new Error('Invalid PLIST tag ' + node.nodeName);
220222
}
221223
}

Diff for: test/parse.js

+20
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,26 @@ int main(int argc, char *argv[])
437437
});
438438
});
439439

440+
it('should fail parsing invalid xml plist', function () {
441+
var xml = multiline(function () {
442+
/*
443+
<?xml version="1.0" encoding="UTF-8"?>
444+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
445+
<plist version="1.0">
446+
<dict>
447+
<key>test</key>
448+
<strong>Testing</strong>
449+
<key>bar</key>
450+
<string></string>
451+
</dict>
452+
</plist>
453+
*/
454+
});
455+
assert.throws(function () {
456+
var parsed = parse(xml);
457+
});
458+
});
459+
440460
it('should parse an example "Xcode-Info.plist" file', function () {
441461
var xml = multiline(function () {
442462
/*

0 commit comments

Comments
 (0)