Skip to content

Commit 3fd73f8

Browse files
committed
version bump 0.13.1: determinism
- pin unknown dates and zero-fill end of file - cfb_add can take an absolute path e.g. "/Workbook"
1 parent d784f9b commit 3fd73f8

16 files changed

+283
-366
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@ dist: dist-deps $(TARGET) ## Prepare JS files for distribution
5353

5454
.PHONY: dist-deps
5555
dist-deps: xlscfb.js ## Copy dependencies for distribution
56-
cp xlscfb.js dist/xlscfb.js
56+
cp xlscfb.flow.js dist/xlscfb.js
5757

5858
.PHONY: aux
5959
aux: $(AUXTARGETS)
6060

6161
.PHONY: xls
6262
xls: xlscfb.js
6363

64-
XLSDEPS=misc/suppress_export.js $(filter-out bits/08_blob.js,$(DEPS))
64+
XLSSKIP=bits/08_blob.js bits/04_base64.js bits/05_buf.js
65+
XLSDEPS=misc/suppress_export.js $(filter-out $(XLSSKIP),$(DEPS))
6566
xlscfb.flow.js: $(XLSDEPS) ## Build support library
6667
cat $^ | tr -d '\15\32' > $@
6768

bits/31_version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
exports.version = '0.13.0';
1+
exports.version = '0.13.1';

bits/56_dirtree.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var now = new Date(), j = 0;
1+
var now = new Date(1987, 1, 19), j = 0;
22
var data/*:Array<[string, CFBEntry]>*/ = [];
33
for(i = 0; i < cfb.FullPaths.length; ++i) {
44
if(cfb.FileIndex[i].type === 0) continue;

bits/68_mini.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
for(; j & 0x3F; ++j) o.write_shift(1, 0);
77
}
88
}
9-
9+
while(o.l < o.length) o.write_shift(1, 0);

bits/85_api.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ function cfb_add(cfb/*:CFBContainer*/, name/*:string*/, content/*:?RawBytes*/, o
88
init_cfb(cfb);
99
var file = CFB.find(cfb, name);
1010
if(!file) {
11+
var fpath = cfb.FullPaths[0];
12+
if(name.slice(0, fpath.length) == fpath) fpath = name;
13+
else {
14+
if(fpath.slice(-1) != "/") fpath += "/";
15+
fpath = (fpath + name).replace("//","/");
16+
}
1117
file = ({name: filename(name)}/*:any*/);
1218
cfb.FileIndex.push(file);
13-
cfb.FullPaths.push(name);
19+
cfb.FullPaths.push(fpath);
1420
CFB.utils.cfb_gc(cfb);
1521
}
1622
/*:: if(!file) throw new Error("unreachable"); */

cfb.flow.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ type CFBFiles = {[n:string]:CFBEntry};
179179
/* [MS-CFB] v20130118 */
180180
var CFB = (function _CFB(){
181181
var exports/*:CFBModule*/ = /*::(*/{}/*:: :any)*/;
182-
exports.version = '0.13.0';
182+
exports.version = '0.13.1';
183183
/* [MS-CFB] 2.6.4 */
184184
function namecmp(l/*:string*/, r/*:string*/)/*:number*/ {
185185
var L = l.split("/"), R = r.split("/");
@@ -552,7 +552,7 @@ function rebuild_cfb(cfb/*:CFBContainer*/, f/*:?boolean*/)/*:void*/ {
552552
}
553553
if(!gc && !f) return;
554554

555-
var now = new Date(), j = 0;
555+
var now = new Date(1987, 1, 19), j = 0;
556556
var data/*:Array<[string, CFBEntry]>*/ = [];
557557
for(i = 0; i < cfb.FullPaths.length; ++i) {
558558
if(cfb.FileIndex[i].type === 0) continue;
@@ -730,7 +730,7 @@ function _write(cfb/*:CFBContainer*/, options/*:CFBWriteOpts*/)/*:RawBytes*/ {
730730
for(; j & 0x3F; ++j) o.write_shift(1, 0);
731731
}
732732
}
733-
733+
while(o.l < o.length) o.write_shift(1, 0);
734734
return o;
735735
}
736736
/* [MS-CFB] 2.6.4 (Unicode 3.0.1 case conversion) */
@@ -809,9 +809,15 @@ function cfb_add(cfb/*:CFBContainer*/, name/*:string*/, content/*:?RawBytes*/, o
809809
init_cfb(cfb);
810810
var file = CFB.find(cfb, name);
811811
if(!file) {
812+
var fpath = cfb.FullPaths[0];
813+
if(name.slice(0, fpath.length) == fpath) fpath = name;
814+
else {
815+
if(fpath.slice(-1) != "/") fpath += "/";
816+
fpath = (fpath + name).replace("//","/");
817+
}
812818
file = ({name: filename(name)}/*:any*/);
813819
cfb.FileIndex.push(file);
814-
cfb.FullPaths.push(name);
820+
cfb.FullPaths.push(fpath);
815821
CFB.utils.cfb_gc(cfb);
816822
}
817823
/*:: if(!file) throw new Error("unreachable"); */

cfb.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function new_buf(sz) {
161161
/* [MS-CFB] v20130118 */
162162
var CFB = (function _CFB(){
163163
var exports = {};
164-
exports.version = '0.13.0';
164+
exports.version = '0.13.1';
165165
/* [MS-CFB] 2.6.4 */
166166
function namecmp(l, r) {
167167
var L = l.split("/"), R = r.split("/");
@@ -534,7 +534,7 @@ function rebuild_cfb(cfb, f) {
534534
}
535535
if(!gc && !f) return;
536536

537-
var now = new Date(), j = 0;
537+
var now = new Date(1987, 1, 19), j = 0;
538538
var data = [];
539539
for(i = 0; i < cfb.FullPaths.length; ++i) {
540540
if(cfb.FileIndex[i].type === 0) continue;
@@ -707,7 +707,7 @@ if(file.size > 0 && file.size < 0x1000) {
707707
for(; j & 0x3F; ++j) o.write_shift(1, 0);
708708
}
709709
}
710-
710+
while(o.l < o.length) o.write_shift(1, 0);
711711
return o;
712712
}
713713
/* [MS-CFB] 2.6.4 (Unicode 3.0.1 case conversion) */
@@ -785,9 +785,15 @@ function cfb_add(cfb, name, content, opts) {
785785
init_cfb(cfb);
786786
var file = CFB.find(cfb, name);
787787
if(!file) {
788+
var fpath = cfb.FullPaths[0];
789+
if(name.slice(0, fpath.length) == fpath) fpath = name;
790+
else {
791+
if(fpath.slice(-1) != "/") fpath += "/";
792+
fpath = (fpath + name).replace("//","/");
793+
}
788794
file = ({name: filename(name)});
789795
cfb.FileIndex.push(file);
790-
cfb.FullPaths.push(name);
796+
cfb.FullPaths.push(fpath);
791797
CFB.utils.cfb_gc(cfb);
792798
}
793799
file.content = (content);

dist/cfb.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function new_buf(sz) {
161161
/* [MS-CFB] v20130118 */
162162
var CFB = (function _CFB(){
163163
var exports = {};
164-
exports.version = '0.13.0';
164+
exports.version = '0.13.1';
165165
/* [MS-CFB] 2.6.4 */
166166
function namecmp(l, r) {
167167
var L = l.split("/"), R = r.split("/");
@@ -534,7 +534,7 @@ function rebuild_cfb(cfb, f) {
534534
}
535535
if(!gc && !f) return;
536536

537-
var now = new Date(), j = 0;
537+
var now = new Date(1987, 1, 19), j = 0;
538538
var data = [];
539539
for(i = 0; i < cfb.FullPaths.length; ++i) {
540540
if(cfb.FileIndex[i].type === 0) continue;
@@ -707,7 +707,7 @@ if(file.size > 0 && file.size < 0x1000) {
707707
for(; j & 0x3F; ++j) o.write_shift(1, 0);
708708
}
709709
}
710-
710+
while(o.l < o.length) o.write_shift(1, 0);
711711
return o;
712712
}
713713
/* [MS-CFB] 2.6.4 (Unicode 3.0.1 case conversion) */
@@ -785,9 +785,15 @@ function cfb_add(cfb, name, content, opts) {
785785
init_cfb(cfb);
786786
var file = CFB.find(cfb, name);
787787
if(!file) {
788+
var fpath = cfb.FullPaths[0];
789+
if(name.slice(0, fpath.length) == fpath) fpath = name;
790+
else {
791+
if(fpath.slice(-1) != "/") fpath += "/";
792+
fpath = (fpath + name).replace("//","/");
793+
}
788794
file = ({name: filename(name)});
789795
cfb.FileIndex.push(file);
790-
cfb.FullPaths.push(name);
796+
cfb.FullPaths.push(fpath);
791797
CFB.utils.cfb_gc(cfb);
792798
}
793799
file.content = (content);

0 commit comments

Comments
 (0)