File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,7 +19,10 @@ function JSZip() {
1919 // "folder/" : {...},
2020 // "folder/data.txt" : {...}
2121 // }
22- this . files = { } ;
22+ // NOTE: we use a null prototype because we do not
23+ // want filenames like "toString" coming from a zip file
24+ // to overwrite methods and attributes in a normal Object.
25+ this . files = Object . create ( null ) ;
2326
2427 this . comment = null ;
2528
Original file line number Diff line number Diff line change @@ -179,16 +179,16 @@ var out = {
179179 */
180180 forEach : function ( cb ) {
181181 var filename , relativePath , file ;
182+ /* jshint ignore:start */
183+ // ignore warning about unwanted properties because this.files is a null prototype object
182184 for ( filename in this . files ) {
183- if ( ! this . files . hasOwnProperty ( filename ) ) {
184- continue ;
185- }
186185 file = this . files [ filename ] ;
187186 relativePath = filename . slice ( this . root . length , filename . length ) ;
188187 if ( relativePath && filename . slice ( 0 , this . root . length ) === this . root ) { // the file is in the current root
189188 cb ( relativePath , file ) ; // TODO reverse the parameters ? need to be clean AND consistent with the filter search fn...
190189 }
191190 }
191+ /* jshint ignore:end */
192192 } ,
193193
194194 /**
You can’t perform that action at this time.
0 commit comments