@@ -6,19 +6,22 @@ module.exports = function(extraField, vars) {
66 while ( ! extra && extraField && extraField . length ) {
77 const candidateExtra = parseBuffer . parse ( extraField , [
88 [ 'signature' , 2 ] ,
9- [ 'partsize' , 2 ] ,
10- [ 'uncompressedSize' , 8 ] ,
11- [ 'compressedSize' , 8 ] ,
12- [ 'offset' , 8 ] ,
13- [ 'disknum' , 8 ] ,
9+ [ 'partSize' , 2 ] ,
1410 ] ) ;
1511
1612 if ( candidateExtra . signature === 0x0001 ) {
17- extra = candidateExtra ;
13+ // parse buffer based on data in ZIP64 central directory; order is important!
14+ const fieldsToExpect = [ ] ;
15+ if ( vars . uncompressedSize === 0xffffffff ) fieldsToExpect . push ( [ 'uncompressedSize' , 8 ] ) ;
16+ if ( vars . compressedSize === 0xffffffff ) fieldsToExpect . push ( [ 'compressedSize' , 8 ] ) ;
17+ if ( vars . offsetToLocalFileHeader === 0xffffffff ) fieldsToExpect . push ( [ 'offsetToLocalFileHeader' , 8 ] ) ;
18+
19+ // slice off the 4 bytes for signature and partSize
20+ extra = parseBuffer . parse ( extraField . slice ( 4 ) , fieldsToExpect ) ;
1821 } else {
1922 // Advance the buffer to the next part.
2023 // The total size of this part is the 4 byte header + partsize.
21- extraField = extraField . slice ( candidateExtra . partsize + 4 ) ;
24+ extraField = extraField . slice ( candidateExtra . partSize + 4 ) ;
2225 }
2326 }
2427
@@ -31,7 +34,7 @@ module.exports = function(extraField, vars) {
3134 vars . uncompressedSize = extra . uncompressedSize ;
3235
3336 if ( vars . offsetToLocalFileHeader === 0xffffffff )
34- vars . offsetToLocalFileHeader = extra . offset ;
37+ vars . offsetToLocalFileHeader = extra . offsetToLocalFileHeader ;
3538
3639 return extra ;
3740} ;
0 commit comments