Skip to content

Commit

Permalink
Merge pull request #88 from trufae/parse-hard
Browse files Browse the repository at this point in the history
Be more strict when parsing plists
  • Loading branch information
mreinstein authored Apr 26, 2022
2 parents 64c2fbf + be43f31 commit 4031a9d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: ci

on:
push:
pull_request:

jobs:
build:
Expand Down
2 changes: 2 additions & 0 deletions lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,7 @@ function parsePlistXML (node) {

} else if (node.nodeName === 'false') {
return false;
} else {
throw new Error('Invalid PLIST tag ' + node.nodeName);
}
}
26 changes: 26 additions & 0 deletions test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,4 +519,30 @@ int main(int argc, char *argv[])
});
});
});
describe('invalid formats', function () {
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('ensure empty strings arent valid plist', function () {
assert.throws(function () {
var parsed = parse('');
});
});
});
});

0 comments on commit 4031a9d

Please sign in to comment.