styled-exceljs 0.21.4 → 0.21.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "styled-exceljs",
3
- "version": "0.21.4",
3
+ "version": "0.21.6",
4
4
  "author": "sheetjs",
5
5
  "description": "SheetJS CE fork with enhanced XLS/XLSX styling and browser rendering",
6
6
  "keywords": [
@@ -140,12 +140,14 @@
140
140
  },
141
141
  "repository": {
142
142
  "type": "git",
143
- "url": "https://git.sheetjs.com/SheetJS/sheetjs"
143
+ "url": "git+https://github.com/flyfish-dev/styled-exceljs.git"
144
144
  },
145
145
  "scripts": {
146
146
  "test": "make travis",
147
147
  "test:security": "node tests/security-prototype-pollution.mjs",
148
148
  "test:table-styles": "node tests/table-styles.mjs",
149
+ "test:cfb-minifat": "node tests/cfb-minifat.mjs && XLSX_TEST_MODULE=./xlsx.mjs node tests/cfb-minifat.mjs",
150
+ "test:corpus": "node node_modules/mocha/bin/mocha.js --require ./tests/runtime-identity.cjs -R dot -t 30000 test.js && node node_modules/mocha/bin/mocha.js --require ./tests/runtime-identity.cjs -R dot -t 30000 test.mjs",
149
151
  "build": "make",
150
152
  "lint": "make fullint",
151
153
  "dtslint": "dtslint types"
@@ -166,7 +168,7 @@
166
168
  "holes"
167
169
  ]
168
170
  },
169
- "homepage": "https://sheetjs.com/",
171
+ "homepage": "https://github.com/flyfish-dev/styled-exceljs#readme",
170
172
  "files": [
171
173
  "CHANGELOG.md",
172
174
  "LICENSE",
@@ -187,7 +189,7 @@
187
189
  "types/tsconfig.json"
188
190
  ],
189
191
  "bugs": {
190
- "url": "https://git.sheetjs.com/SheetJS/sheetjs/issues"
192
+ "url": "https://github.com/flyfish-dev/styled-exceljs/issues"
191
193
  },
192
194
  "license": "Apache-2.0",
193
195
  "engines": {
package/xlsx.js CHANGED
@@ -4,7 +4,7 @@
4
4
  /*global global, exports, module, require:false, process:false, Buffer:false, ArrayBuffer:false, DataView:false, Deno:false, Set:false, Float32Array:false, Int8Array:false */
5
5
  var XLSX = {};
6
6
  function make_xlsx_lib(XLSX){
7
- XLSX.version = '0.21.4';
7
+ XLSX.version = '0.21.6';
8
8
  var current_codepage = 1200, current_ansi = 1252;
9
9
  /*global cptable:true, window */
10
10
  var $cptable;
@@ -1663,8 +1663,12 @@ sleuth_fat(difat_start, difat_sec_cnt, sectors, ssz, fat_addrs);
1663
1663
  /** Chains */
1664
1664
  var sector_list = make_sector_list(sectors, dir_start, fat_addrs, ssz);
1665
1665
 
1666
- if(dir_start < sector_list.length) sector_list[dir_start].name = "!Directory";
1667
- if(nmfs > 0 && minifat_start !== ENDOFCHAIN) sector_list[minifat_start].name = "!MiniFAT";
1666
+ if(!sector_list[dir_start]) throw new Error("CFB directory chain is missing");
1667
+ sector_list[dir_start].name = "!Directory";
1668
+ /* A stale MiniFAT location is irrelevant when no live entry uses mini streams.
1669
+ * Validate required chains when reading their live directory entries. */
1670
+ if(nmfs > 0 && sector_list[minifat_start]) sector_list[minifat_start].name = "!MiniFAT";
1671
+ if(!sector_list[fat_addrs[0]]) throw new Error("CFB FAT chain is missing");
1668
1672
  sector_list[fat_addrs[0]].name = "!FAT";
1669
1673
  sector_list.fat_addrs = fat_addrs;
1670
1674
  sector_list.ssz = ssz;
@@ -1876,10 +1880,14 @@ function read_directory(dir_start, sector_list, sectors, Paths, nmfs, files, Fil
1876
1880
  if(mtime !== 0) o.mt = read_date(blob, blob.l-8);
1877
1881
  o.start = blob.read_shift(4, 'i');
1878
1882
  o.size = blob.read_shift(4, 'i');
1883
+ if(o.type === 0) { o.size = 0; o.start = ENDOFCHAIN; }
1879
1884
  if(o.size < 0 && o.start < 0) { o.size = o.type = 0; o.start = ENDOFCHAIN; o.name = ""; }
1880
1885
  if(o.type === 5) { /* root */
1881
- minifat_store = o.start;
1882
- if(nmfs > 0 && minifat_store !== ENDOFCHAIN) sector_list[minifat_store].name = "!StreamData";
1886
+ minifat_store = o.size > 0 ? o.start : ENDOFCHAIN;
1887
+ if(o.size > 0 && nmfs > 0) {
1888
+ if(!sector_list[minifat_store]) throw new Error("CFB root mini stream is missing");
1889
+ sector_list[minifat_store].name = "!StreamData";
1890
+ }
1883
1891
  /*minifat_size = o.size;*/
1884
1892
  } else if(o.size >= 4096 /* MSCSZ */) {
1885
1893
  o.storage = 'fat';
@@ -1889,8 +1897,11 @@ function read_directory(dir_start, sector_list, sectors, Paths, nmfs, files, Fil
1889
1897
  } else {
1890
1898
  o.storage = 'minifat';
1891
1899
  if(o.size < 0) o.size = 0;
1892
- else if(minifat_store !== ENDOFCHAIN && o.start !== ENDOFCHAIN && sector_list[minifat_store]) {
1893
- o.content = get_mfat_entry(o, sector_list[minifat_store].data, (sector_list[mini]||{}).data);
1900
+ else if(o.type === 2 && o.size > 0) {
1901
+ if(nmfs < 1 || !sector_list[mini]) throw new Error("CFB MiniFAT chain is missing for stream: " + o.name);
1902
+ if(!sector_list[minifat_store]) throw new Error("CFB root mini stream is missing");
1903
+ o.content = get_mfat_entry(o, sector_list[minifat_store].data, sector_list[mini].data);
1904
+ if(o.content.length !== o.size) throw new Error("CFB mini stream is truncated: " + o.name);
1894
1905
  }
1895
1906
  }
1896
1907
  if(o.content) prep_blob(o.content, 0);
@@ -3220,7 +3231,6 @@ exports.utils = {
3220
3231
 
3221
3232
  return exports;
3222
3233
  })();
3223
-
3224
3234
  var _fs;
3225
3235
  function set_fs(fs) { _fs = fs; }
3226
3236
 
package/xlsx.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  /*exported XLSX */
4
4
  /*global process:false, Buffer:false, ArrayBuffer:false, DataView:false, Deno:false */
5
5
  var XLSX = {};
6
- XLSX.version = '0.21.4';
6
+ XLSX.version = '0.21.6';
7
7
  var current_codepage = 1200, current_ansi = 1252;
8
8
  /*:: declare var cptable:any; */
9
9
  /*global cptable:true, window */
@@ -1725,8 +1725,12 @@ sleuth_fat(difat_start, difat_sec_cnt, sectors, ssz, fat_addrs);
1725
1725
  /** Chains */
1726
1726
  var sector_list/*:SectorList*/ = make_sector_list(sectors, dir_start, fat_addrs, ssz);
1727
1727
 
1728
- if(dir_start < sector_list.length) sector_list[dir_start].name = "!Directory";
1729
- if(nmfs > 0 && minifat_start !== ENDOFCHAIN) sector_list[minifat_start].name = "!MiniFAT";
1728
+ if(!sector_list[dir_start]) throw new Error("CFB directory chain is missing");
1729
+ sector_list[dir_start].name = "!Directory";
1730
+ /* A stale MiniFAT location is irrelevant when no live entry uses mini streams.
1731
+ * Validate required chains when reading their live directory entries. */
1732
+ if(nmfs > 0 && sector_list[minifat_start]) sector_list[minifat_start].name = "!MiniFAT";
1733
+ if(!sector_list[fat_addrs[0]]) throw new Error("CFB FAT chain is missing");
1730
1734
  sector_list[fat_addrs[0]].name = "!FAT";
1731
1735
  sector_list.fat_addrs = fat_addrs;
1732
1736
  sector_list.ssz = ssz;
@@ -1938,10 +1942,14 @@ function read_directory(dir_start/*:number*/, sector_list/*:SectorList*/, sector
1938
1942
  if(mtime !== 0) o.mt = read_date(blob, blob.l-8);
1939
1943
  o.start = blob.read_shift(4, 'i');
1940
1944
  o.size = blob.read_shift(4, 'i');
1945
+ if(o.type === 0) { o.size = 0; o.start = ENDOFCHAIN; }
1941
1946
  if(o.size < 0 && o.start < 0) { o.size = o.type = 0; o.start = ENDOFCHAIN; o.name = ""; }
1942
1947
  if(o.type === 5) { /* root */
1943
- minifat_store = o.start;
1944
- if(nmfs > 0 && minifat_store !== ENDOFCHAIN) sector_list[minifat_store].name = "!StreamData";
1948
+ minifat_store = o.size > 0 ? o.start : ENDOFCHAIN;
1949
+ if(o.size > 0 && nmfs > 0) {
1950
+ if(!sector_list[minifat_store]) throw new Error("CFB root mini stream is missing");
1951
+ sector_list[minifat_store].name = "!StreamData";
1952
+ }
1945
1953
  /*minifat_size = o.size;*/
1946
1954
  } else if(o.size >= 4096 /* MSCSZ */) {
1947
1955
  o.storage = 'fat';
@@ -1951,8 +1959,11 @@ function read_directory(dir_start/*:number*/, sector_list/*:SectorList*/, sector
1951
1959
  } else {
1952
1960
  o.storage = 'minifat';
1953
1961
  if(o.size < 0) o.size = 0;
1954
- else if(minifat_store !== ENDOFCHAIN && o.start !== ENDOFCHAIN && sector_list[minifat_store]) {
1955
- o.content = get_mfat_entry(o, sector_list[minifat_store].data, (sector_list[mini]||{}).data);
1962
+ else if(o.type === 2 && o.size > 0) {
1963
+ if(nmfs < 1 || !sector_list[mini]) throw new Error("CFB MiniFAT chain is missing for stream: " + o.name);
1964
+ if(!sector_list[minifat_store]) throw new Error("CFB root mini stream is missing");
1965
+ o.content = get_mfat_entry(o, sector_list[minifat_store].data, sector_list[mini].data);
1966
+ if(o.content.length !== o.size) throw new Error("CFB mini stream is truncated: " + o.name);
1956
1967
  }
1957
1968
  }
1958
1969
  if(o.content) prep_blob(o.content, 0);
@@ -3288,7 +3299,6 @@ exports.utils = {
3288
3299
 
3289
3300
  return exports;
3290
3301
  })();
3291
-
3292
3302
  var _fs;
3293
3303
  function set_fs(fs) { _fs = fs; }
3294
3304