Skip to content

Commit

Permalink
Be more strict when parsing plists
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae authored and radare committed Apr 26, 2022
1 parent 730c3dd commit d90ff97
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,7 @@ function parsePlistXML (node) {

} else if (node.nodeName === 'false') {
return false;
} else {
throw new Error('Invalid PLIST tag ' + node.nodeName);
}
}
20 changes: 20 additions & 0 deletions test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,26 @@ int main(int argc, char *argv[])
});
});

it('should fail parsing invalid xml plist', function () {
var xml = multiline(function () {
/*
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>test</key>
<strong>Testing</strong>
<key>bar</key>
<string></string>
</dict>
</plist>
*/
});
assert.throws(function () {
var parsed = parse(xml);
});
});

it('should parse an example "Xcode-Info.plist" file', function () {
var xml = multiline(function () {
/*
Expand Down

0 comments on commit d90ff97

Please sign in to comment.