Skip to content

Commit ebfb5bc

Browse files
committed
properly detect encrypted ODS
1 parent 222995e commit ebfb5bc

File tree

4 files changed

+48
-14
lines changed

4 files changed

+48
-14
lines changed

bits/77_parsetab.js

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -844,12 +844,10 @@ var XLSBRecordEnum = {
844844
var XLSBRE = evert_key(XLSBRecordEnum, 'n');
845845
XLSBRE["BrtFRTArchID$"] = 0x0010;
846846

847-
/* [MS-XLS] 2.3 Record Enumeration */
847+
/* [MS-XLS] 2.3 Record Enumeration (and other sources) */
848848
var XLSRecordEnum = {
849-
/*::[*/0x0003/*::]*/: { n:"BIFF2NUM", f:parse_BIFF2NUM },
850-
/*::[*/0x0004/*::]*/: { n:"BIFF2STR", f:parse_BIFF2STR },
849+
/* [MS-XLS] 2.3 Record Enumeration 2021-08-17 */
851850
/*::[*/0x0006/*::]*/: { n:"Formula", f:parse_Formula },
852-
/*::[*/0x0009/*::]*/: { n:'BOF', f:parse_BOF },
853851
/*::[*/0x000a/*::]*/: { n:'EOF', f:parsenoop2 },
854852
/*::[*/0x000c/*::]*/: { n:"CalcCount", f:parseuint16 },
855853
/*::[*/0x000d/*::]*/: { n:"CalcMode", f:parseuint16 },
@@ -870,7 +868,6 @@ var XLSRecordEnum = {
870868
/*::[*/0x001d/*::]*/: { n:"Selection" },
871869
/*::[*/0x0022/*::]*/: { n:"Date1904", f:parsebool },
872870
/*::[*/0x0023/*::]*/: { n:"ExternName", f:parse_ExternName },
873-
/*::[*/0x0024/*::]*/: { n:"COLWIDTH" },
874871
/*::[*/0x0026/*::]*/: { n:"LeftMargin", f:parse_Xnum },
875872
/*::[*/0x0027/*::]*/: { n:"RightMargin", f:parse_Xnum },
876873
/*::[*/0x0028/*::]*/: { n:"TopMargin", f:parse_Xnum },
@@ -1040,7 +1037,6 @@ var XLSRecordEnum = {
10401037
/*::[*/0x0203/*::]*/: { n:"Number", f:parse_Number },
10411038
/*::[*/0x0204/*::]*/: { n:"Label", f:parse_Label },
10421039
/*::[*/0x0205/*::]*/: { n:"BoolErr", f:parse_BoolErr },
1043-
/*::[*/0x0206/*::]*/: { n:"Formula", f:parse_Formula },
10441040
/*::[*/0x0207/*::]*/: { n:"String", f:parse_String },
10451041
/*::[*/0x0208/*::]*/: { n:'Row', f:parse_Row },
10461042
/*::[*/0x020b/*::]*/: { n:"Index" },
@@ -1050,7 +1046,6 @@ var XLSRecordEnum = {
10501046
/*::[*/0x023e/*::]*/: { n:"Window2", f:parse_Window2 },
10511047
/*::[*/0x027e/*::]*/: { n:"RK", f:parse_RK },
10521048
/*::[*/0x0293/*::]*/: { n:"Style" },
1053-
/*::[*/0x0406/*::]*/: { n:"Formula", f:parse_Formula },
10541049
/*::[*/0x0418/*::]*/: { n:"BigName" },
10551050
/*::[*/0x041e/*::]*/: { n:"Format", f:parse_Format },
10561051
/*::[*/0x043c/*::]*/: { n:"ContinueBigName" },
@@ -1207,20 +1202,49 @@ var XLSRecordEnum = {
12071202
/*::[*/0x1068/*::]*/: { n:"Fbi2" },
12081203

12091204
/*::[*/0x0000/*::]*/: { n:"Dimensions", f:parse_Dimensions },
1205+
/*::[*/0x0001/*::]*/: { n:"BIFF2BLANK" },
12101206
/*::[*/0x0002/*::]*/: { n:"BIFF2INT", f:parse_BIFF2INT },
1207+
/*::[*/0x0003/*::]*/: { n:"BIFF2NUM", f:parse_BIFF2NUM },
1208+
/*::[*/0x0004/*::]*/: { n:"BIFF2STR", f:parse_BIFF2STR },
12111209
/*::[*/0x0005/*::]*/: { n:"BoolErr", f:parse_BoolErr },
12121210
/*::[*/0x0007/*::]*/: { n:"String", f:parse_BIFF2STRING },
12131211
/*::[*/0x0008/*::]*/: { n:"BIFF2ROW" },
1212+
/*::[*/0x0009/*::]*/: { n:'BOF', f:parse_BOF },
12141213
/*::[*/0x000b/*::]*/: { n:"Index" },
12151214
/*::[*/0x0016/*::]*/: { n:"ExternCount", f:parseuint16 },
12161215
/*::[*/0x001e/*::]*/: { n:"BIFF2FORMAT", f:parse_BIFF2Format },
12171216
/*::[*/0x001f/*::]*/: { n:"BIFF2FMTCNT" }, /* 16-bit cnt of BIFF2FORMAT records */
12181217
/*::[*/0x0020/*::]*/: { n:"BIFF2COLINFO" },
12191218
/*::[*/0x0021/*::]*/: { n:"Array", f:parse_Array },
1219+
/*::[*/0x0024/*::]*/: { n:"COLWIDTH" },
12201220
/*::[*/0x0025/*::]*/: { n:"DefaultRowHeight", f:parse_DefaultRowHeight },
1221+
// 0x2c ??
1222+
// 0x2d ??
1223+
// 0x2e ??
1224+
// 0x30 FONTCOUNT: number of fonts
12211225
/*::[*/0x0032/*::]*/: { n:"BIFF2FONTXTRA", f:parse_BIFF2FONTXTRA },
1222-
/*::[*/0x0034/*::]*/: { n:"DDEObjName" },
1226+
// 0x35: INFOOPTS
1227+
// 0x36: TABLE (BIFF2 only)
1228+
// 0x37: TABLE2 (BIFF2 only)
1229+
// 0x38: WNDESK
1230+
// 0x39 ??
1231+
// 0x3a: BEGINPREF
1232+
// 0x3b: ENDPREF
12231233
/*::[*/0x003e/*::]*/: { n:"BIFF2WINDOW2" },
1234+
// 0x3f ??
1235+
// 0x46: SHOWSCROLL
1236+
// 0x47: SHOWFORMULA
1237+
// 0x48: STATUSBAR
1238+
// 0x49: SHORTMENUS
1239+
// 0x4A:
1240+
// 0x4B:
1241+
// 0x4C:
1242+
// 0x4E:
1243+
// 0x4F:
1244+
// 0x58: TOOLBAR (BIFF3)
1245+
1246+
/* - - - */
1247+
/*::[*/0x0034/*::]*/: { n:"DDEObjName" },
12241248
/*::[*/0x0043/*::]*/: { n:"BIFF2XF" },
12251249
/*::[*/0x0044/*::]*/: { n:"BIFF2XFINDEX", f:parseuint16 },
12261250
/*::[*/0x0045/*::]*/: { n:"BIFF2FONTCLR" },
@@ -1230,10 +1254,18 @@ var XLSRecordEnum = {
12301254
/*::[*/0x0087/*::]*/: { n:"Addin" },
12311255
/*::[*/0x0088/*::]*/: { n:"Edg" },
12321256
/*::[*/0x0089/*::]*/: { n:"Pub" },
1257+
// 0x8A
1258+
// 0x8B LH: alternate menu key flag (BIFF3/4)
1259+
// 0x8E
1260+
// 0x8F
12331261
/*::[*/0x0091/*::]*/: { n:"Sub" },
1262+
// 0x93 STYLE
12341263
/*::[*/0x0094/*::]*/: { n:"LHRecord" },
12351264
/*::[*/0x0095/*::]*/: { n:"LHNGraph" },
12361265
/*::[*/0x0096/*::]*/: { n:"Sound" },
1266+
// 0xA2 FNPROTO: function prototypes (BIFF4)
1267+
// 0xA3
1268+
// 0xA8
12371269
/*::[*/0x00a9/*::]*/: { n:"CoordList" },
12381270
/*::[*/0x00ab/*::]*/: { n:"GCW" },
12391271
/*::[*/0x00bc/*::]*/: { n:"ShrFmla" }, /* Not necessarily same as 0x04bc */
@@ -1246,11 +1278,13 @@ var XLSRecordEnum = {
12461278
/*::[*/0x00ea/*::]*/: { n:"TabIdConf" },
12471279
/*::[*/0x0162/*::]*/: { n:"XL5Modify" },
12481280
/*::[*/0x01a5/*::]*/: { n:"FileSharing2" },
1281+
/*::[*/0x0206/*::]*/: { n:"Formula", f:parse_Formula },
12491282
/*::[*/0x0209/*::]*/: { n:'BOF', f:parse_BOF },
12501283
/*::[*/0x0218/*::]*/: { n:"Lbl", f:parse_Lbl },
12511284
/*::[*/0x0223/*::]*/: { n:"ExternName", f:parse_ExternName },
12521285
/*::[*/0x0231/*::]*/: { n:"Font" },
12531286
/*::[*/0x0243/*::]*/: { n:"BIFF3XF" },
1287+
/*::[*/0x0406/*::]*/: { n:"Formula", f:parse_Formula },
12541288
/*::[*/0x0409/*::]*/: { n:'BOF', f:parse_BOF },
12551289
/*::[*/0x0443/*::]*/: { n:"BIFF4XF" },
12561290
/*::[*/0x086d/*::]*/: { n:"FeatInfo" },

bits/80_parseods.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -556,11 +556,10 @@ var parse_content_xml = (function() {
556556

557557
function parse_ods(zip/*:ZIPFile*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
558558
opts = opts || ({}/*:any*/);
559-
var ods = !!safegetzipfile(zip, 'objectdata');
560-
if(ods) parse_manifest(getzipdata(zip, 'META-INF/manifest.xml'), opts);
559+
if(safegetzipfile(zip, 'META-INF/manifest.xml')) parse_manifest(getzipdata(zip, 'META-INF/manifest.xml'), opts);
561560
var content = getzipstr(zip, 'content.xml');
562-
if(!content) throw new Error("Missing content.xml in " + (ods ? "ODS" : "UOF")+ " file");
563-
var wb = parse_content_xml(ods ? content : utf8read(content), opts);
561+
if(!content) throw new Error("Missing content.xml in ODS / UOF file");
562+
var wb = parse_content_xml(utf8read(content), opts);
564563
if(safegetzipfile(zip, 'meta.xml')) wb.Props = parse_core_props(getzipdata(zip, 'meta.xml'));
565564
return wb;
566565
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@
4646
"devDependencies": {
4747
"@sheetjs/uglify-js": "~2.7.3",
4848
"@types/node": "^8.5.9",
49+
"acorn": "7.4.1",
4950
"alex": "^9.1.0",
5051
"blanket": "~1.2.3",
5152
"dtslint": "^0.1.2",
52-
"eslint": "^7.23.0",
53+
"eslint": "7.23.0",
5354
"eslint-plugin-html": "^6.1.2",
5455
"eslint-plugin-json": "^2.1.2",
5556
"jsdom": "~11.1.0",

tests.lst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ apachepoi_MatrixFormulaEvalTestData.xlsx
227227
apachepoi_NewStyleConditionalFormattings.xlsx
228228
apachepoi_NewlineInFormulas.xlsx
229229
# apachepoi_NumberFormatApproxTests.xlsx # xlml
230-
apachepoi_NumberFormatTests.xlsx
230+
apachepoi_NumberFormatTests.xlsx # upstream changed file
231231
apachepoi_RepeatingRowsCols.xlsx
232232
apachepoi_SampleSS.strict.xlsx
233233
apachepoi_SampleSS.xlsx

0 commit comments

Comments
 (0)