Skip to content

Commit 8508ad4

Browse files
committed
version bump 0.12.2: BIFF2-4 features
- correct BIFF-dependent cell reference wrapping - record layout fixes from sample files - use BIFF version 2.4.338 for BOF (fixes #995 h/t @benjaminleetmaa) - fixed potentially vulnerable regexes (h/t @davisjam) - removed insecure deep dependency (fixes #996 h/t @dcatoday)
1 parent 88e9e31 commit 8508ad4

36 files changed

+259
-201
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tmp
1212
*.[pP][rR][nN]
1313
*.[sS][lL][kK]
1414
*.socialcalc
15-
*.[xX][lL][sSwWcCaAtT]
15+
*.[xX][lL][sSwWcCaAtTmM]
1616
*.[xX][lL][sSaAtT][xXmMbB]
1717
*.[oO][dD][sS]
1818
*.[fF][oO][dD][sS]

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ tmp
1414
*.[pP][rR][nN]
1515
*.[sS][lL][kK]
1616
*.socialcalc
17-
*.[xX][lL][sSwWcCaAtT]
17+
*.[xX][lL][sSwWcCaAtTmM]
1818
*.[xX][lL][sSaAtT][xXmMbB]
1919
*.[oO][dD][sS]
2020
*.[fF][oO][dD][sS]

bits/01_version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
XLSX.version = '0.12.1';
1+
XLSX.version = '0.12.2';

bits/10_ssf.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*jshint -W041 */
33
var SSF/*:SSFModule*/ = ({}/*:any*/);
44
var make_ssf = function make_ssf(SSF/*:SSFModule*/){
5-
SSF.version = '0.10.0';
5+
SSF.version = '0.10.2';
66
function _strrev(x/*:string*/)/*:string*/ { var o = "", i = x.length-1; while(i>=0) o += x.charAt(i--); return o; }
77
function fill(c/*:string*/,l/*:number*/)/*:string*/ { var o = ""; while(o.length < l) o+=c; return o; }
88
function pad0(v/*:any*/,d/*:number*/)/*:string*/{var t=""+v; return t.length>=d?t:fill('0',d-t.length)+t;}
@@ -791,7 +791,7 @@ function eval_fmt(fmt/*:string*/, v/*:any*/, opts/*:any*/, flen/*:number*/) {
791791
}
792792
SSF._eval = eval_fmt;
793793
var cfregex = /\[[=<>]/;
794-
var cfregex2 = /\[([=<>]*)(-?\d+\.?\d*)\]/;
794+
var cfregex2 = /\[(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)\]/;
795795
function chkcond(v, rr) {
796796
if(rr == null) return false;
797797
var thresh = parseFloat(rr[2]);

bits/22_xmlutils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n';
22
var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g;
3-
var tagregex=/<[\/\?]?[a-zA-Z0-9:]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s]+))*\s?[\/\?]?>/g;
3+
var tagregex=/<[\/\?]?[a-zA-Z0-9:]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/g;
44
if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g;
55
var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/;
66
function parsexmltag(tag/*:string*/, skip_root/*:?boolean*/)/*:any*/ {

bits/23_binutils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function write_double_le(b/*:RawBytes|CFBlob*/, v/*:number*/, idx/*:number*/) {
2525
b[idx + 7] = (e >> 4) | bs;
2626
}
2727

28-
var __toBuffer = function(bufs/*:Array<any>*/) { var x=[],w=10240; for(var i=0;i<bufs[0].length;++i) for(var j=0,L=bufs[0][i].length;j<L;j+=w) x.push.apply(x, bufs[0][i].slice(j,j+w)); return x; };
28+
var __toBuffer = function(bufs/*:Array<Array<RawBytes> >*/)/*:RawBytes*/ { var x=[],w=10240; for(var i=0;i<bufs[0].length;++i) if(bufs[0][i]) for(var j=0,L=bufs[0][i].length;j<L;j+=w) x.push.apply(x, bufs[0][i].slice(j,j+w)); return x; };
2929
var ___toBuffer = __toBuffer;
3030
var __utf16le = function(b/*:RawBytes|CFBlob*/,s/*:number*/,e/*:number*/)/*:string*/ { var ss/*:Array<string>*/=[]; for(var i=s; i<e; i+=2) ss.push(String.fromCharCode(__readUInt16LE(b,i))); return ss.join("").replace(chr0,''); };
3131
var ___utf16le = __utf16le;

bits/25_cellutils.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ function shift_range_xls(cell, range, opts) {
2222
return out;
2323
}
2424

25-
function encode_cell_xls(c/*:CellAddress*/)/*:string*/ {
25+
function encode_cell_xls(c/*:CellAddress*/, biff/*:number*/)/*:string*/ {
26+
if(c.cRel && c.c < 0) { c = dup(c); c.c += (biff > 8) ? 0x4000 : 0x100; }
27+
if(c.rRel && c.r < 0) { c = dup(c); c.r += (biff > 8) ? 0x100000 : ((biff > 5) ? 0x10000 : 0x4000); }
2628
var s = encode_cell(c);
2729
if(c.cRel === 0) s = fix_col(s);
2830
if(c.rRel === 0) s = fix_row(s);
@@ -31,7 +33,7 @@ function encode_cell_xls(c/*:CellAddress*/)/*:string*/ {
3133

3234
function encode_range_xls(r, opts)/*:string*/ {
3335
if(r.s.r == 0 && !r.s.rRel) {
34-
if(r.e.r == (opts.biff >= 12 ? 0xFFFFF : 0xFFFF) && !r.e.rRel) {
36+
if(r.e.r == (opts.biff >= 12 ? 0xFFFFF : (opts.biff >= 8 ? 0x10000 : 0x4000)) && !r.e.rRel) {
3537
return (r.s.cRel ? "" : "$") + encode_col(r.s.c) + ":" + (r.e.cRel ? "" : "$") + encode_col(r.e.c);
3638
}
3739
}
@@ -40,5 +42,5 @@ function encode_range_xls(r, opts)/*:string*/ {
4042
return (r.s.rRel ? "" : "$") + encode_row(r.s.r) + ":" + (r.e.rRel ? "" : "$") + encode_row(r.e.r);
4143
}
4244
}
43-
return encode_cell_xls(r.s) + ":" + encode_cell_xls(r.e);
45+
return encode_cell_xls(r.s, opts.biff) + ":" + encode_cell_xls(r.e, opts.biff);
4446
}

bits/29_xlsenum.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var VT_UI4 = 0x0013;
2323
var VT_LPSTR = 0x001E;
2424
//var VT_LPWSTR = 0x001F;
2525
var VT_FILETIME = 0x0040;
26-
//var VT_BLOB = 0x0041;
26+
var VT_BLOB = 0x0041;
2727
//var VT_STREAM = 0x0042;
2828
//var VT_STORAGE = 0x0043;
2929
//var VT_STREAMED_Object = 0x0044;
@@ -61,6 +61,7 @@ var DocSummaryPIDDSI = {
6161
/*::[*/0x13/*::]*/: { n: 'SharedDoc', t: VT_BOOL },
6262
/*::[*/0x16/*::]*/: { n: 'HLinksChanged', t: VT_BOOL },
6363
/*::[*/0x17/*::]*/: { n: 'AppVersion', t: VT_I4, p: 'version' },
64+
/*::[*/0x18/*::]*/: { n: 'DigSig', t: VT_BLOB },
6465
/*::[*/0x1A/*::]*/: { n: 'ContentType', t: VT_STRING },
6566
/*::[*/0x1B/*::]*/: { n: 'ContentStatus', t: VT_STRING },
6667
/*::[*/0x1C/*::]*/: { n: 'Language', t: VT_STRING },

bits/38_xlstypes.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ function parse_dictionary(blob,CodePage) {
8383
function parse_BLOB(blob) {
8484
var size = blob.read_shift(4);
8585
var bytes = blob.slice(blob.l,blob.l+size);
86+
blob.l += size;
8687
if((size & 3) > 0) blob.l += (4 - (size & 3)) & 3;
8788
return bytes;
8889
}
@@ -93,7 +94,7 @@ function parse_ClipboardData(blob) {
9394
var o = {};
9495
o.Size = blob.read_shift(4);
9596
//o.Format = blob.read_shift(4);
96-
blob.l += o.Size;
97+
blob.l += o.Size + 3 - (o.Size - 1) % 4;
9798
return o;
9899
}
99100

@@ -239,6 +240,7 @@ function parse_PropertySetStream(file, PIDSI, clsid) {
239240
rval.FMTID = FMTID0;
240241
//rval.PSet0 = PSet0;
241242
if(NumSets === 1) return rval;
243+
if(Offset1 - blob.l == 2) blob.l += 2;
242244
if(blob.l !== Offset1) throw new Error("Length mismatch 2: " + blob.l + " !== " + Offset1);
243245
var PSet1;
244246
try { PSet1 = parse_PropertySet(blob, null); } catch(e) {/* empty */}

bits/39_xlsbiff.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ function parse_BOF(blob, length) {
155155
switch(o.BIFFVer) {
156156
case 0x0600: /* BIFF8 */
157157
case 0x0500: /* BIFF5 */
158+
case 0x0400: /* BIFF4 */
159+
case 0x0300: /* BIFF3 */
160+
case 0x0200: /* BIFF2 */
158161
case 0x0002: case 0x0007: /* BIFF2 */
159162
break;
160163
default: if(length > 6) throw new Error("Unexpected BIFF Ver " + o.BIFFVer);

0 commit comments

Comments
 (0)