js-cfb/bits/41_mver.js
SheetJS fcc05e3567 version bump 0.10.2: proper directory/FAT analysis
- reprocess directory sector lists if not available
- search now strips out OLE metacharacters \0-\5
- strip sourceMappingURL references from minified scripts (h/t @vinin3)
- added xlscfb.js for js-xls
2014-11-02 23:02:42 -05:00

34 lines
835 B
JavaScript

/* [MS-CFB] 2.2 Compound File Header -- read up to major version */
function check_get_mver(blob) {
// header signature 8
blob.chk(HEADER_SIGNATURE, 'Header Signature: ');
// clsid 16
blob.chk(HEADER_CLSID, 'CLSID: ');
// minor version 2
var mver = blob.read_shift(2, 'u');
return [blob.read_shift(2,'u'), mver];
}
function check_shifts(blob, mver) {
var shift = 0x09;
// Byte Order
blob.chk('feff', 'Byte Order: ');
// Sector Shift
switch((shift = blob.read_shift(2))) {
case 0x09: if(mver !== 3) throw 'MajorVersion/SectorShift Mismatch'; break;
case 0x0c: if(mver !== 4) throw 'MajorVersion/SectorShift Mismatch'; break;
default: throw 'Sector Shift: Expected 9 or 12 saw ' + shift;
}
// Mini Sector Shift
blob.chk('0600', 'Mini Sector Shift: ');
// Reserved
blob.chk('000000000000', 'Reserved: ');
}