@@ -1803,12 +1803,15 @@ var vtregex = (function(){ var vt_cache = {};
18031803 return (vt_cache[bt] = new RegExp("<(?:vt:)?" + bt + ">([\\s\\S]*?)</(?:vt:)?" + bt + ">", 'g') );
18041804};})();
18051805var vtvregex = /<\/?(?:vt:)?variant>/g, vtmregex = /<(?:vt:)([^>]*)>([\s\S]*)</;
1806- function parseVector(data) {
1806+ function parseVector(data, opts ) {
18071807 var h = parsexmltag(data);
18081808
18091809 var matches = data.match(vtregex(h.baseType))||[];
1810- if(matches.length != h.size) throw new Error("unexpected vector length " + matches.length + " != " + h.size);
18111810 var res = [];
1811+ if(matches.length != h.size) {
1812+ if(opts.WTF) throw new Error("unexpected vector length " + matches.length + " != " + h.size);
1813+ return res;
1814+ }
18121815 matches.forEach(function(x) {
18131816 var v = x.replace(vtvregex,"").match(vtmregex);
18141817 res.push({v:utf8read(v[2]), t:v[1]});
@@ -3408,7 +3411,7 @@ var EXT_PROPS/*:Array<Array<string> >*/ = [
34083411XMLNS.EXT_PROPS = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties";
34093412RELS.EXT_PROPS = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties';
34103413
3411- function parse_ext_props(data, p) {
3414+ function parse_ext_props(data, p, opts ) {
34123415 var q = {}; if(!p) p = {};
34133416
34143417 EXT_PROPS.forEach(function(f) {
@@ -3423,10 +3426,10 @@ function parse_ext_props(data, p) {
34233426 });
34243427
34253428 if(q.HeadingPairs && q.TitlesOfParts) {
3426- var v = parseVector(q.HeadingPairs);
3427- var parts = parseVector(q.TitlesOfParts).map(function(x) { return x.v; });
3429+ var v = parseVector(q.HeadingPairs, opts );
3430+ var parts = parseVector(q.TitlesOfParts, opts ).map(function (x) { return x.v; });
34283431 var idx = 0, len = 0;
3429- for(var i = 0; i !== v.length; i+= 2) {
3432+ if(parts.length > 0) for(var i = 0; i !== v.length; i += 2) {
34303433 len = +(v[i+1].v);
34313434 switch(v[i].v) {
34323435 case "Worksheets":
@@ -17279,7 +17282,7 @@ function parse_zip(zip/*:ZIP*/, opts/*:?ParseOpts*/)/*:Workbook*/ {
1727917282 if(propdata) props = parse_core_props(propdata);
1728017283 if(dir.extprops.length !== 0) {
1728117284 propdata = getzipstr(zip, dir.extprops[0].replace(/^\//,''), true);
17282- if(propdata) parse_ext_props(propdata, props);
17285+ if(propdata) parse_ext_props(propdata, props, opts );
1728317286 }
1728417287 }
1728517288
0 commit comments