Skip to content

Commit

Permalink
Fix invalid plist build when serializing a null
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae authored and radare committed Apr 26, 2022
1 parent 24d38d3 commit 1c16e2d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,8 @@ function walk_obj(next, next_child) {
// a typed array
next_child.ele('data').raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child));

} else if ('Null' === name) {
next_child.ele('null').txt('');

}
}
13 changes: 13 additions & 0 deletions test/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@ describe('plist', function () {
*/}));
});

it('should not omit null values', function () {
var xml = build({ a: null});
assert.strictEqual(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>a</key>
<null/>
</dict>
</plist>
*/}));
});
});

});

0 comments on commit 1c16e2d

Please sign in to comment.