File tree 2 files changed +7
-4
lines changed 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,10 @@ function JSZip() {
19
19
// "folder/" : {...},
20
20
// "folder/data.txt" : {...}
21
21
// }
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 ) ;
23
26
24
27
this . comment = null ;
25
28
Original file line number Diff line number Diff line change @@ -179,16 +179,16 @@ var out = {
179
179
*/
180
180
forEach : function ( cb ) {
181
181
var filename , relativePath , file ;
182
+ /* jshint ignore:start */
183
+ // ignore warning about unwanted properties because this.files is a null prototype object
182
184
for ( filename in this . files ) {
183
- if ( ! this . files . hasOwnProperty ( filename ) ) {
184
- continue ;
185
- }
186
185
file = this . files [ filename ] ;
187
186
relativePath = filename . slice ( this . root . length , filename . length ) ;
188
187
if ( relativePath && filename . slice ( 0 , this . root . length ) === this . root ) { // the file is in the current root
189
188
cb ( relativePath , file ) ; // TODO reverse the parameters ? need to be clean AND consistent with the filter search fn...
190
189
}
191
190
}
191
+ /* jshint ignore:end */
192
192
} ,
193
193
194
194
/**
You can’t perform that action at this time.
0 commit comments