@@ -9,6 +9,7 @@ const temp = require('temp');
99const UNCOMPRESSED_SIZE = 5368709120 ;
1010const ZIP64_OFFSET = 72 ;
1111const ZIP64_SIZE = 36 ;
12+ const ZIP64_EXTRA_FIELD_OFFSET = 0 ;
1213
1314t . test ( 'Correct uncompressed size for zip64' , function ( t ) {
1415 const archive = path . join ( __dirname , '../testData/big.zip' ) ;
@@ -43,7 +44,77 @@ t.test('Correct uncompressed size for zip64', function (t) {
4344 t . end ( ) ;
4445} ) ;
4546
46- t . test ( 'Parse files from zip64 format correctly' , function ( t ) {
47+ t . test ( 'Parse files with all zip64 extra fields correctly' , function ( t ) {
48+ const archive = path . join ( __dirname , '../testData/zip64-allextrafields.zip' ) ;
49+
50+ t . test ( 'in unzipper.Open' , function ( t ) {
51+ unzip . Open . file ( archive )
52+ . then ( function ( d ) {
53+ d . files [ 0 ] . stream ( )
54+ . on ( 'vars' , function ( vars ) {
55+ t . same ( vars . extra . uncompressedSize , ZIP64_SIZE , 'Open: Extra field' ) ;
56+ t . same ( vars . extra . compressedSize , ZIP64_SIZE , 'Open: Extra field' ) ;
57+ t . same ( vars . extra . offsetToLocalFileHeader , ZIP64_EXTRA_FIELD_OFFSET , 'Open: Extra field' ) ;
58+ t . same ( vars . uncompressedSize , ZIP64_SIZE , 'Open: File header' ) ;
59+ t . same ( vars . compressedSize , ZIP64_SIZE , 'Open: File header' ) ;
60+ t . same ( vars . offsetToLocalFileHeader , ZIP64_EXTRA_FIELD_OFFSET , 'Open: File header' ) ;
61+ t . end ( ) ;
62+ } )
63+ . on ( 'error' , function ( e ) {
64+ t . same ( e . message , 'FILE_ENDED' ) ;
65+ t . end ( ) ;
66+ } ) ;
67+ } ) ;
68+ } ) ;
69+
70+ t . test ( 'in unzipper.extract' , function ( t ) {
71+ temp . mkdir ( 'node-unzip-' , function ( err , dirPath ) {
72+ if ( err ) {
73+ throw err ;
74+ }
75+ fs . createReadStream ( archive )
76+ . pipe ( unzip . Extract ( { path : dirPath } ) )
77+ . on ( 'close' , function ( ) { t . end ( ) ; } ) ;
78+ } ) ;
79+ } ) ;
80+
81+ t . end ( ) ;
82+ } ) ;
83+
84+ t . test ( 'Parse files with zip64 extra field with only offset length correctly' , function ( t ) {
85+ const archive = path . join ( __dirname , '../testData/zip64-extrafieldoffsetlength.zip' ) ;
86+
87+ t . test ( 'in unzipper.Open' , function ( t ) {
88+ unzip . Open . file ( archive )
89+ . then ( function ( d ) {
90+ d . files [ 0 ] . stream ( )
91+ . on ( 'vars' , function ( vars ) {
92+ t . same ( vars . extra . offsetToLocalFileHeader , ZIP64_EXTRA_FIELD_OFFSET , 'Open: Extra field' ) ;
93+ t . same ( vars . offsetToLocalFileHeader , ZIP64_EXTRA_FIELD_OFFSET , 'Open: File header' ) ;
94+ t . end ( ) ;
95+ } )
96+ . on ( 'error' , function ( e ) {
97+ t . same ( e . message , 'FILE_ENDED' ) ;
98+ t . end ( ) ;
99+ } ) ;
100+ } ) ;
101+ } ) ;
102+
103+ t . test ( 'in unzipper.extract' , function ( t ) {
104+ temp . mkdir ( 'node-unzip-' , function ( err , dirPath ) {
105+ if ( err ) {
106+ throw err ;
107+ }
108+ fs . createReadStream ( archive )
109+ . pipe ( unzip . Extract ( { path : dirPath } ) )
110+ . on ( 'close' , function ( ) { t . end ( ) ; } ) ;
111+ } ) ;
112+ } ) ;
113+
114+ t . end ( ) ;
115+ } ) ;
116+
117+ t . test ( 'Parse files from regular zip64 format correctly' , function ( t ) {
47118 const archive = path . join ( __dirname , '../testData/zip64.zip' ) ;
48119
49120 t . test ( 'in unzipper.Open' , function ( t ) {
0 commit comments