version bump 0.5.10-b: guard against corrupt SSF

- prevent overriding format code 0
- pivot table styles
This commit is contained in:
SheetJS 2014-02-26 14:30:32 -05:00
parent ecee362e00
commit 49a37c9cf5
13 changed files with 38 additions and 42 deletions

@ -30,9 +30,6 @@ TESTFMT=$(patsubst %,test_%,$(FMT))
$(TESTFMT): test_%:
FMTS=$* make test
.PHONY: jasmine
jasmine:
npm run-script test-jasmine
.PHONY: lint
lint: $(TARGET)

@ -1,7 +1,7 @@
#!/usr/bin/env node
/* xlsx.js (C) 2013-2014 SheetJS -- http://sheetjs.com */
var n = "xlsx";
/* vim: set ts=2: */
/* vim: set ts=2 ft=javascript: */
var X = require('../');
var fs = require('fs'), program = require('commander');
program

@ -1 +1 @@
XLSX.version = '0.5.10-a';
XLSX.version = '0.5.10-b';

@ -5,7 +5,7 @@ function parsexmltag(tag) {
var z = {'0': words[0]};
if(words.length === 1) return z;
(tag.match(attregexg) || []).map(
function(x){var y=x.match(attregex); z[y[1]] = y[2].substr(1,y[2].length-2); });
function(x){var y=x.match(attregex); z[y[1].replace(/^[a-zA-Z]*:/,"")] = y[2].substr(1,y[2].length-2); });
return z;
}

@ -8,7 +8,7 @@ function parseNumFmts(t) {
case '<numFmts': case '</numFmts>': case '<numFmts/>': break;
case '<numFmt': {
var f=unescapexml(y.formatCode), i=parseInt(y.numFmtId,10);
styles.NumberFmt[i] = f; SSF.load(f,i);
styles.NumberFmt[i] = f; if(i>0) SSF.load(f,i);
} break;
default: throw 'unrecognized ' + y[0] + ' in numFmts';
}

37
dist/xlsx.js vendored

@ -423,7 +423,7 @@ SSF.load_table = function(tbl) { for(var i=0; i!=0x0188; ++i) if(tbl[i]) SSF.loa
make_ssf(SSF);
var XLSX = {};
(function(XLSX){
XLSX.version = '0.5.10';
XLSX.version = '0.5.10-b';
var current_codepage, current_cptable, cptable;
if(typeof module !== "undefined" && typeof require !== 'undefined') {
if(typeof cptable === 'undefined') cptable = require('codepage');
@ -476,7 +476,7 @@ function parsexmltag(tag) {
var z = {'0': words[0]};
if(words.length === 1) return z;
(tag.match(attregexg) || []).map(
function(x){var y=x.match(attregex); z[y[1]] = y[2].substr(1,y[2].length-2); });
function(x){var y=x.match(attregex); z[y[1].replace(/^[a-zA-Z]*:/,"")] = y[2].substr(1,y[2].length-2); });
return z;
}
@ -518,20 +518,20 @@ function parsexmlbool(value, tag) {
}
var utf8read = function(orig) {
var out = "", i = 0, c = 0, c1 = 0, c2 = 0, c3 = 0;
var out = [], i = 0, c = 0, c1 = 0, c2 = 0, c3 = 0;
while (i < orig.length) {
c = orig.charCodeAt(i++);
if (c < 128) out += _chr(c);
if (c < 128) out.push(_chr(c));
else {
c2 = orig.charCodeAt(i++);
if (c>191 && c<224) out += _chr((c & 31) << 6 | c2 & 63);
if (c>191 && c<224) out.push(_chr((c & 31) << 6 | c2 & 63));
else {
c3 = orig.charCodeAt(i++);
out += _chr((c & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
out.push(_chr((c & 15) << 12 | (c2 & 63) << 6 | c3 & 63));
}
}
}
return out;
return out.join("");
};
// matches <foo>...</foo> extracts content
@ -590,7 +590,7 @@ var __readDoubleLE = function(b, idx) { return b.readDoubleLE ? b.readDoubleLE(i
function ReadShift(size, t) {
var o, w, vv, i, loc; t = t || 'u';
var o = "", oo = [], w, vv, i, loc; t = t || 'u';
if(size === 'ieee754') { size = 8; t = 'f'; }
switch(size) {
case 1: o = __readUInt8(this, this.l); break;
@ -602,11 +602,11 @@ function ReadShift(size, t) {
/* sbcs and dbcs support continue records in the SST way TODO codepages */
/* TODO: DBCS http://msdn.microsoft.com/en-us/library/cc194788.aspx */
case 'dbcs': size = 2*t; o = ""; loc = this.l;
case 'dbcs': size = 2*t; loc = this.l;
for(i = 0; i != t; ++i) {
o += _getchar(__readUInt16LE(this, loc));
oo.push(_getchar(__readUInt16LE(this, loc)));
loc+=2;
} break;
} o = oo.join(""); break;
case 'sbcs': size = t; o = ""; loc = this.l;
for(i = 0; i != t; ++i) {
@ -906,7 +906,7 @@ function parseNumFmts(t) {
case '<numFmts': case '</numFmts>': case '<numFmts/>': break;
case '<numFmt': {
var f=unescapexml(y.formatCode), i=parseInt(y.numFmtId,10);
styles.NumberFmt[i] = f; SSF.load(f,i);
styles.NumberFmt[i] = f; if(i>0) SSF.load(f,i);
} break;
default: throw 'unrecognized ' + y[0] + ' in numFmts';
}
@ -1332,10 +1332,7 @@ function parse_ws_xml(data, opts) {
cells.forEach(function(c, idx) { if(c === "" || c.trim() === "") return;
var cref = c.match(/r=["']([^"']*)["']/);
c = "<c " + c;
if(cref && cref.length == 2) {
var cref_cell = decode_cell(cref[1]);
idx = cref_cell.c;
}
if(cref && cref.length == 2) idx = decode_cell(cref[1]).c;
var cell = parsexmltag((c.match(/<c[^>]*>/)||[c])[0]); delete cell[0];
var d = c.substr(c.indexOf('>')+1);
var p = {};
@ -2935,9 +2932,9 @@ function sheet_to_csv(sheet, opts) {
default: throw 'unrecognized type ' + val.t;
}
};
var out = "", txt = "";
var out = [], txt = "";
opts = opts || {};
if(!sheet || !sheet["!ref"]) return out;
if(!sheet || !sheet["!ref"]) return "";
var r = XLSX.utils.decode_range(sheet["!ref"]);
var fs = opts.FS||",", rs = opts.RS||"\n";
@ -2951,9 +2948,9 @@ function sheet_to_csv(sheet, opts) {
txt = "\"" + txt.replace(/"/g, '""') + "\"";
row.push(txt);
}
out += row.join(fs) + (rs);
out.push(row.join(fs));
}
return out;
return out.join(rs) + (out.length ? rs : "");
}
var make_csv = sheet_to_csv;

6
dist/xlsx.min.js vendored

File diff suppressed because one or more lines are too long

2
dist/xlsx.min.map vendored

File diff suppressed because one or more lines are too long

@ -1,6 +1,6 @@
{
"name": "xlsx",
"version": "0.5.10-a",
"version": "0.5.10-b",
"author": "sheetjs",
"description": "XLSB / XLSX / XLSM parser",
"keywords": [ "xlsx", "xlsb", "xlsm", "office", "excel", "spreadsheet" ],

@ -57,9 +57,9 @@ function parsetest(x, wb) {
var name = (dir + x + '.' + i + '.csv');
if(x.substr(-5) === ".xlsb") {
root = x.slice(0,-5);
//if(!fs.existsSync(name)) name=(dir + root + '.xlsx.'+i+'.csv');
//if(!fs.existsSync(name)) name=(dir + root + '.xlsm.'+i+'.csv');
//if(!fs.existsSync(name)) name=(dir + root + '.xls.'+i+'.csv');
if(!fs.existsSync(name)) name=(dir + root + '.xlsx.'+i+'.csv');
if(!fs.existsSync(name)) name=(dir + root + '.xlsm.'+i+'.csv');
if(!fs.existsSync(name)) name=(dir + root + '.xls.'+i+'.csv');
}
it('#' + i + ' (' + ws + ')', fs.existsSync(name) ? function() {
var file = fs.readFileSync(name, 'utf-8');
@ -145,7 +145,7 @@ describe('options', function() {
var ws = wb.Sheets[s];
Object.keys(ws).forEach(function(addr) {
if(addr[0] === "!" || !ws.hasOwnProperty(addr)) return;
assert(typeof ws[addr].t!== 'n' || typeof ws[addr].z !== 'undefined');
assert(ws[addr].t!== 'n' || typeof ws[addr].z !== 'undefined');
});
});
});

@ -6,6 +6,7 @@ large_strings.xlsb
merge_cells.xlsb
named_ranges_2011.xlsb
number_format.xlsb
pivot_table_test.xlsb
rich_text_stress.xlsb
time_stress_test_1.xlsb
xlsx-stream-d-date-cell.xlsb
@ -162,7 +163,7 @@ jxls-core_simple.xlsx
jxls-examples_stress1.xlsx
jxls-examples_stress2.xlsx
jxls-reader_departmentData.xlsx
large_strings.xlsx
large_strings.xlsx.pending
merge_cells.xlsx
mixed_sheets.xlsx
named_ranges_2011.xlsx
@ -233,11 +234,12 @@ xlrd_reveng1.xlsx
xlrd_test_comments_excel.xlsx
xlrd_test_comments_gdocs.xlsx
xlrd_text_bar.xlsx
חישוב_נקודות_זיכוי.xlsx
xlsx-stream-d-date-cell.xlsx
חישוב_נקודות_זיכוי.xlsx
apachepoi_45431.xlsm
apachepoi_47026.xlsm
apachepoi_47089.xlsm
apachepoi_ExcelWithAttachments.xlsm
number_format.xlsm
openpyxl_r_vba-test.xlsm
pivot_table_test.xlsm

@ -1 +1 @@
Subproject commit aad3f9c021d2b70fd4c288e001085b168eba6baf
Subproject commit e0c5c7ddb3cbaf4f70c1cd7e5c9fe1597aa2f4da

@ -423,7 +423,7 @@ SSF.load_table = function(tbl) { for(var i=0; i!=0x0188; ++i) if(tbl[i]) SSF.loa
make_ssf(SSF);
var XLSX = {};
(function(XLSX){
XLSX.version = '0.5.10-a';
XLSX.version = '0.5.10-b';
var current_codepage, current_cptable, cptable;
if(typeof module !== "undefined" && typeof require !== 'undefined') {
if(typeof cptable === 'undefined') cptable = require('codepage');
@ -476,7 +476,7 @@ function parsexmltag(tag) {
var z = {'0': words[0]};
if(words.length === 1) return z;
(tag.match(attregexg) || []).map(
function(x){var y=x.match(attregex); z[y[1]] = y[2].substr(1,y[2].length-2); });
function(x){var y=x.match(attregex); z[y[1].replace(/^[a-zA-Z]*:/,"")] = y[2].substr(1,y[2].length-2); });
return z;
}
@ -906,7 +906,7 @@ function parseNumFmts(t) {
case '<numFmts': case '</numFmts>': case '<numFmts/>': break;
case '<numFmt': {
var f=unescapexml(y.formatCode), i=parseInt(y.numFmtId,10);
styles.NumberFmt[i] = f; SSF.load(f,i);
styles.NumberFmt[i] = f; if(i>0) SSF.load(f,i);
} break;
default: throw 'unrecognized ' + y[0] + ' in numFmts';
}