File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -354,6 +354,9 @@ module.exports = function(/*String*/input) {
354
354
355
355
356
356
var target = pth . resolve ( targetPath , maintainEntryPath ? entryName : pth . basename ( entryName ) ) ;
357
+ if ( ! target . startsWith ( targetPath ) ) {
358
+ throw Utils . Errors . INVALID_FILENAME + ": " + entryName ;
359
+ }
357
360
358
361
if ( item . isDirectory ) {
359
362
target = pth . resolve ( target , ".." ) ;
@@ -429,6 +432,10 @@ module.exports = function(/*String*/input) {
429
432
_zip . entries . forEach ( function ( entry ) {
430
433
entryName = entry . entryName . toString ( ) ;
431
434
435
+ if ( ! pth . resolve ( targetPath , entryName ) . startsWith ( targetPath ) ) {
436
+ throw Utils . Errors . INVALID_FILENAME + ": " + entryName ;
437
+ }
438
+
432
439
if ( isWin ) {
433
440
entryName = escapeFileName ( entryName )
434
441
}
@@ -471,6 +478,10 @@ module.exports = function(/*String*/input) {
471
478
entryName = escapeFileName ( entryName )
472
479
}
473
480
481
+ if ( ! pth . resolve ( targetPath , entryName ) . startsWith ( targetPath ) ) {
482
+ throw Utils . Errors . INVALID_FILENAME + ": " + entryName ;
483
+ }
484
+
474
485
if ( entry . isDirectory ) {
475
486
Utils . makeDir ( pth . resolve ( targetPath , entryName ) ) ;
476
487
if ( -- i == 0 )
You can’t perform that action at this time.
0 commit comments