Skip to content
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
2 changes: 1 addition & 1 deletion src/MsgReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,7 @@ export default class MsgReader {
skip = insideProps;
}
else if (decodeAs === "unicode") {
value = removeTrailingNull(ds.readUCS2String(array.length / 2));
value = removeTrailingNull(ds.readUCS2String(Math.floor(array.length / 2)));
skip = insideProps;
}
else if (decodeAs === "binary") {
Expand Down
11 changes: 11 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,17 @@ describe('MsgReader', function () {
generateRegression('attachmentsOrder');
generateRegression('Many entities');

it('reads a unicode property with an odd byte length', function () {
const { burn } = require('../lib/Burner');
const body = new Uint8Array(Buffer.from('Hello'));
const array = burn([
{ name: 'Root Entry', type: TypeEnum.ROOT, length: 0, children: [1] },
{ name: '__substg1.0_1000001F', type: TypeEnum.DOCUMENT, length: body.length, binaryProvider: () => body },
]);
const fields = new MsgReader(array).getFileData();
assert.strictEqual(fields.body, Buffer.from('Hell').toString('utf16le'));
});

});


Expand Down
Loading