File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 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) {
354354
355355
356356 var target = pth . resolve ( targetPath , maintainEntryPath ? entryName : pth . basename ( entryName ) ) ;
357+ if ( ! target . startsWith ( targetPath ) ) {
358+ throw Utils . Errors . INVALID_FILENAME + ": " + entryName ;
359+ }
357360
358361 if ( item . isDirectory ) {
359362 target = pth . resolve ( target , ".." ) ;
@@ -429,6 +432,10 @@ module.exports = function(/*String*/input) {
429432 _zip . entries . forEach ( function ( entry ) {
430433 entryName = entry . entryName . toString ( ) ;
431434
435+ if ( ! pth . resolve ( targetPath , entryName ) . startsWith ( targetPath ) ) {
436+ throw Utils . Errors . INVALID_FILENAME + ": " + entryName ;
437+ }
438+
432439 if ( isWin ) {
433440 entryName = escapeFileName ( entryName )
434441 }
@@ -471,6 +478,10 @@ module.exports = function(/*String*/input) {
471478 entryName = escapeFileName ( entryName )
472479 }
473480
481+ if ( ! pth . resolve ( targetPath , entryName ) . startsWith ( targetPath ) ) {
482+ throw Utils . Errors . INVALID_FILENAME + ": " + entryName ;
483+ }
484+
474485 if ( entry . isDirectory ) {
475486 Utils . makeDir ( pth . resolve ( targetPath , entryName ) ) ;
476487 if ( -- i == 0 )
You can’t perform that action at this time.
0 commit comments