Commit 5771dfc4 by Qiang Xue

Merge pull request #3529 from skotos/3522-normalizepath-current-path

#3522 normalizepath to allow current path
parents b1b6a769 390004a8
......@@ -28,6 +28,7 @@ Yii Framework 2 Change Log
- Bug #3431: Allow using extended ErrorHandler class from the app namespace (cebe)
- Bug #3436: Fixed the issue that `ServiceLocator` still returns the old component after calling `set()` with a new definition (qiangxue)
- Bug #3458: Fixed the bug that the image rendered by `CaptchaAction` was using a wrong content type (MDMunir, qiangxue)
- Bug #3522: Fixed BaseFileHelper::normalizePath to allow a (.) for the current path. (skotos)
- Bug: Fixed inconsistent return of `\yii\console\Application::runAction()` (samdark)
- Enh #2264: `CookieCollection::has()` will return false for expired or removed cookies (qiangxue)
- Enh #2435: `yii\db\IntegrityException` is now thrown on database integrity errors instead of general `yii\db\Exception` (samdark)
......
......@@ -56,7 +56,8 @@ class BaseFileHelper
$parts[] = $part;
}
}
return implode($ds, $parts);
$path = implode($ds, $parts);
return $path === '' ? '.' : $path;
}
/**
......
......@@ -369,10 +369,16 @@ class FileHelperTest extends TestCase
$this->assertEquals("..{$ds}c", FileHelper::normalizePath('//a/.\\b//..//..//../../c'));
// relative paths
$this->assertEquals(".", FileHelper::normalizePath('.'));
$this->assertEquals(".", FileHelper::normalizePath('./'));
$this->assertEquals("a", FileHelper::normalizePath('.\\a'));
$this->assertEquals("a{$ds}b", FileHelper::normalizePath('./a\\b'));
$this->assertEquals(".", FileHelper::normalizePath('./a\\../'));
$this->assertEquals("..{$ds}..{$ds}a", FileHelper::normalizePath('../..\\a'));
$this->assertEquals("..{$ds}..{$ds}a", FileHelper::normalizePath('../..\\a/../a'));
$this->assertEquals("..{$ds}..{$ds}b", FileHelper::normalizePath('../..\\a/../b'));
$this->assertEquals("..{$ds}a", FileHelper::normalizePath('./..\\a'));
$this->assertEquals("..{$ds}a", FileHelper::normalizePath('././..\\a'));
$this->assertEquals("..{$ds}a", FileHelper::normalizePath('./..\\a/../a'));
$this->assertEquals("..{$ds}b", FileHelper::normalizePath('./..\\a/../b'));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment