Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be more strict when parsing plists #88

Merged
merged 3 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -217,5 +217,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('');
});
});
});
});