mirror of
https://github.com/misterunknown/ifm.git
synced 2025-08-13 19:44:02 +02:00
Fix: tmp_dir relative to __DIR__ (zipnload)
Signed-off-by: Marco Dickert <marco@misterunknown.de>
This commit is contained in:
@@ -3884,8 +3884,9 @@ f00bar;
|
|||||||
elseif ( ! $this->isFilenameValid( $d['filename'] ) )
|
elseif ( ! $this->isFilenameValid( $d['filename'] ) )
|
||||||
$this->jsonResponse( array( "status" => "ERROR", "message" => $this->l['invalid_filename'] ) );
|
$this->jsonResponse( array( "status" => "ERROR", "message" => $this->l['invalid_filename'] ) );
|
||||||
else {
|
else {
|
||||||
|
trigger_error("foo bar");
|
||||||
unset( $zip );
|
unset( $zip );
|
||||||
$dfile = $this->pathCombine( $this->config['tmp_dir'], uniqid( "ifm-tmp-" ) . ".zip" ); // temporary filename
|
$dfile = $this->pathCombine( __DIR__, $this->config['tmp_dir'], uniqid( "ifm-tmp-" ) . ".zip" ); // temporary filename
|
||||||
try {
|
try {
|
||||||
IFMArchive::createZip( realpath( $d['filename'] ), $dfile );
|
IFMArchive::createZip( realpath( $d['filename'] ), $dfile );
|
||||||
if( $d['filename'] == "." ) {
|
if( $d['filename'] == "." ) {
|
||||||
@@ -4307,13 +4308,12 @@ f00bar;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// combines two parts to a valid path
|
// combines two parts to a valid path
|
||||||
private function pathCombine( $a, $b ) {
|
private function pathCombine(...$parts) {
|
||||||
if( trim( $a ) == "" && trim( $b ) == "" )
|
$ret = "";
|
||||||
return "";
|
foreach($parts as $part)
|
||||||
elseif( trim( $a ) == "" )
|
if (trim($part) != "")
|
||||||
return ltrim( $b, '/' );
|
$ret .= (empty($ret)?rtrim($part,"/"):trim($part, '/'))."/";
|
||||||
else
|
return rtrim($ret, "/");
|
||||||
return rtrim( $a, '/' ) . '/' . trim( $b, '/' );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if filename is allowed
|
// check if filename is allowed
|
||||||
|
16
ifm.php
16
ifm.php
@@ -3884,8 +3884,9 @@ f00bar;
|
|||||||
elseif ( ! $this->isFilenameValid( $d['filename'] ) )
|
elseif ( ! $this->isFilenameValid( $d['filename'] ) )
|
||||||
$this->jsonResponse( array( "status" => "ERROR", "message" => $this->l['invalid_filename'] ) );
|
$this->jsonResponse( array( "status" => "ERROR", "message" => $this->l['invalid_filename'] ) );
|
||||||
else {
|
else {
|
||||||
|
trigger_error("foo bar");
|
||||||
unset( $zip );
|
unset( $zip );
|
||||||
$dfile = $this->pathCombine( $this->config['tmp_dir'], uniqid( "ifm-tmp-" ) . ".zip" ); // temporary filename
|
$dfile = $this->pathCombine( __DIR__, $this->config['tmp_dir'], uniqid( "ifm-tmp-" ) . ".zip" ); // temporary filename
|
||||||
try {
|
try {
|
||||||
IFMArchive::createZip( realpath( $d['filename'] ), $dfile );
|
IFMArchive::createZip( realpath( $d['filename'] ), $dfile );
|
||||||
if( $d['filename'] == "." ) {
|
if( $d['filename'] == "." ) {
|
||||||
@@ -4307,13 +4308,12 @@ f00bar;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// combines two parts to a valid path
|
// combines two parts to a valid path
|
||||||
private function pathCombine( $a, $b ) {
|
private function pathCombine(...$parts) {
|
||||||
if( trim( $a ) == "" && trim( $b ) == "" )
|
$ret = "";
|
||||||
return "";
|
foreach($parts as $part)
|
||||||
elseif( trim( $a ) == "" )
|
if (trim($part) != "")
|
||||||
return ltrim( $b, '/' );
|
$ret .= (empty($ret)?rtrim($part,"/"):trim($part, '/'))."/";
|
||||||
else
|
return rtrim($ret, "/");
|
||||||
return rtrim( $a, '/' ) . '/' . trim( $b, '/' );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if filename is allowed
|
// check if filename is allowed
|
||||||
|
15
src/main.php
15
src/main.php
@@ -820,7 +820,7 @@ f00bar;
|
|||||||
$this->jsonResponse( array( "status" => "ERROR", "message" => $this->l['invalid_filename'] ) );
|
$this->jsonResponse( array( "status" => "ERROR", "message" => $this->l['invalid_filename'] ) );
|
||||||
else {
|
else {
|
||||||
unset( $zip );
|
unset( $zip );
|
||||||
$dfile = $this->pathCombine( $this->config['tmp_dir'], uniqid( "ifm-tmp-" ) . ".zip" ); // temporary filename
|
$dfile = $this->pathCombine( __DIR__, $this->config['tmp_dir'], uniqid( "ifm-tmp-" ) . ".zip" ); // temporary filename
|
||||||
try {
|
try {
|
||||||
IFMArchive::createZip( realpath( $d['filename'] ), $dfile );
|
IFMArchive::createZip( realpath( $d['filename'] ), $dfile );
|
||||||
if( $d['filename'] == "." ) {
|
if( $d['filename'] == "." ) {
|
||||||
@@ -1242,13 +1242,12 @@ f00bar;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// combines two parts to a valid path
|
// combines two parts to a valid path
|
||||||
private function pathCombine( $a, $b ) {
|
private function pathCombine(...$parts) {
|
||||||
if( trim( $a ) == "" && trim( $b ) == "" )
|
$ret = "";
|
||||||
return "";
|
foreach($parts as $part)
|
||||||
elseif( trim( $a ) == "" )
|
if (trim($part) != "")
|
||||||
return ltrim( $b, '/' );
|
$ret .= (empty($ret)?rtrim($part,"/"):trim($part, '/'))."/";
|
||||||
else
|
return rtrim($ret, "/");
|
||||||
return rtrim( $a, '/' ) . '/' . trim( $b, '/' );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if filename is allowed
|
// check if filename is allowed
|
||||||
|
Reference in New Issue
Block a user