From 07066775c937897852c6d205b41e765c0c541b02 Mon Sep 17 00:00:00 2001 From: bepsvpt Date: Mon, 6 Jan 2020 18:35:56 +0800 Subject: [PATCH 1/3] remove duplicate slash for tempdir path Co-authored-by: bepsvpt Signed-off-by: William Desportes --- libraries/classes/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/classes/Config.php b/libraries/classes/Config.php index 4ba9cbdb9a..3ddb793e1a 100644 --- a/libraries/classes/Config.php +++ b/libraries/classes/Config.php @@ -1673,7 +1673,7 @@ class Config if (empty($path)) { $path = null; } else { - $path .= '/' . $name; + $path = rtrim($path, '/') . '/' . $name; if (! @is_dir($path)) { @mkdir($path, 0770, true); } From 21c2bcdbb321c8bae9ada556c35975002f9b001f Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 6 Jan 2020 14:52:02 +0100 Subject: [PATCH 2/3] Add Unit tests Closes #15752 Signed-off-by: William Desportes --- test/classes/ConfigTest.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/classes/ConfigTest.php b/test/classes/ConfigTest.php index f32f9005d0..be234167ce 100644 --- a/test/classes/ConfigTest.php +++ b/test/classes/ConfigTest.php @@ -1007,6 +1007,39 @@ class ConfigTest extends PmaTestCase ); } + /** + * Test for getTempDir + * + * @return void + * + * @group file-system + */ + public function testGetTempDir(): void + { + $this->object->set('TempDir', sys_get_temp_dir() . DIRECTORY_SEPARATOR); + // Check no double slash is here + $this->assertEquals( + sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'upload', + $this->object->getTempDir('upload') + ); + } + + /** + * Test for getUploadTempDir + * + * @return void + * + * @group file-system + */ + public function testGetUploadTempDir(): void + { + $this->object->set('TempDir', sys_get_temp_dir() . DIRECTORY_SEPARATOR); + $this->assertEquals( + $this->object->getTempDir('upload'), + $this->object->getUploadTempDir() + ); + } + /** * Test for isGitRevision * From 4129e16edca5af4d0799edeeb18be19ccfa43333 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 6 Jan 2020 21:30:22 +0100 Subject: [PATCH 3/3] Fix #15752 - use DIRECTORY_SEPARATOR instead of slash Signed-off-by: William Desportes --- libraries/classes/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/classes/Config.php b/libraries/classes/Config.php index 3ddb793e1a..675296033b 100644 --- a/libraries/classes/Config.php +++ b/libraries/classes/Config.php @@ -1673,7 +1673,7 @@ class Config if (empty($path)) { $path = null; } else { - $path = rtrim($path, '/') . '/' . $name; + $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name; if (! @is_dir($path)) { @mkdir($path, 0770, true); }