Skip to content

file found but asBinary reads beyond range in nodejs #126

@SheetJSDev

Description

@SheetJSDev

https://www.dropbox.com/s/w2hwdzfax6ci70y/apachepoi_46535.xlsx

The subfile 'xl/worksheets/sheet4.xml' exists and jszip confirms:

> new JSZip(fs.readFileSync('./apachepoi_46535.xlsx')).files['xl/worksheets/sheet4.xml']
{ name: 'xl/worksheets/sheet4.xml',
  _data:
   { compressedSize: 6162,
     uncompressedSize: 38279,
     crc32: -1943988139,
     compressionMethod: '\b\u0000',
     compressedContent: null,
     getCompressedContent: [Function],
     getContent: [Function] },
  options:
   { binary: true,
     optimizedBinaryString: true,
     date: Tue Jan 01 1980 00:00:00 GMT-0800 (Pacific Standard Time),
     dir: false,
     base64: false,
     compression: null } }

However, trying to read the file using .asBinary() throws an error:

> new JSZip(fs.readFileSync('./apachepoi_46535.xlsx')).files['xl/worksheets/sheet4.xml'].asBinary()
RangeError: Offset/length out of range.
    at Object.fnTyped.arraySet (c:\Users\me\Documents\GitHub\js-xlsx\node_module
s\jszip\node_modules\pako\lib\zlib\utils.js:44:12)
    at Object.inflate (c:\Users\me\Documents\GitHub\js-xlsx\node_modules\jszip\n
ode_modules\pako\lib\zlib\inflate.js:932:13)
    at Inflate.push (c:\Users\me\Documents\GitHub\js-xlsx\node_modules\jszip\nod
e_modules\pako\lib\inflate.js:176:27)
    at inflate (c:\Users\me\Documents\GitHub\js-xlsx\node_modules\jszip\node_mod
ules\pako\lib\inflate.js:277:12)
    at Object.inflateRaw (c:\Users\me\Documents\GitHub\js-xlsx\node_modules\jszi
p\node_modules\pako\lib\inflate.js:297:10)
    at Object.exports.uncompress (c:\Users\me\Documents\GitHub\js-xlsx\node_modu
les\jszip\lib\flate.js:13:17)
    at Object.getContent (c:\Users\me\Documents\GitHub\js-xlsx\node_modules\jszi
p\lib\zipEntry.js:64:52)
    at getRawData (c:\Users\me\Documents\GitHub\js-xlsx\node_modules\jszip\lib\o
bject.js:28:33)
    at Object.dataToString (c:\Users\me\Documents\GitHub\js-xlsx\node_modules\js
zip\lib\object.js:76:18)
    at Object.ZipObject.asBinary (c:\Users\me\Documents\GitHub\js-xlsx\node_modu
les\jszip\lib\object.js:125:29)

Note that this works using [email protected] (which uses zlibjs)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions