File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
app/code/Magento/ImportExport/Model/Import/Source
lib/internal/Magento/Framework/Archive Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ public function __construct(
32
32
throw new ValidatorException (__ ('Sorry, but the data is invalid or the file is not uploaded. ' ));
33
33
}
34
34
$ directory ->delete ($ directory ->getRelativePath ($ file ));
35
- parent ::__construct ($ csvFile , $ directory , $ options );
35
+
36
+ try {
37
+ parent ::__construct ($ csvFile , $ directory , $ options );
38
+ } catch (\LogicException $ e ) {
39
+ $ directory ->delete ($ directory ->getRelativePath ($ csvFile ));
40
+ throw $ e ;
41
+ }
36
42
}
37
43
}
Original file line number Diff line number Diff line change @@ -54,7 +54,8 @@ public function unpack($source, $destination)
54
54
$ zip = new \ZipArchive ();
55
55
if ($ zip ->open ($ source ) === true ) {
56
56
$ filename = $ this ->filterRelativePaths ($ zip ->getNameIndex (0 ) ?: '' );
57
- if ($ filename ) {
57
+ if ($ filename && !preg_match ('#[:"*?|<>%]# ' , $ filename )) {
58
+ // extract first entry in zip file to destination directory
58
59
$ zip ->extractTo (dirname ($ destination ), $ filename );
59
60
rename (dirname ($ destination ).'/ ' .$ filename , $ destination );
60
61
} else {
You can’t perform that action at this time.
0 commit comments