mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 14:26:54 +08:00
Fixes #13034: Fixed normalizePath
for windows network shares that start with two backslashes
This commit is contained in:

committed by
Alexander Makarov

parent
67f67e3a69
commit
06ebd3faa7
@ -18,6 +18,7 @@ Yii Framework 2 Change Log
|
||||
- Enh #15496: CSRF token is now regenerated on changing identity (samdark, rhertogh)
|
||||
- Enh #15417: Added `yii\validators\FileValidator::$minFiles` (vladis84)
|
||||
- Bug #8983: Only truncate the original log file for rotation (matthewyang, developeruz)
|
||||
- Bug #13034: Fixed `normalizePath` for windows network shares that start with two backslashes (developeruz)
|
||||
- Bug #14135: Fixed `yii\web\Request::getBodyParam()` crashes on object type body params (klimov-paul)
|
||||
- Bug #14157: Add support for loading default value `CURRENT_TIMESTAMP` of MySQL `datetime` field (rossoneri)
|
||||
- Bug #14276: Fixed I18N format with dotted parameters (developeruz)
|
||||
|
@ -62,7 +62,11 @@ class BaseFileHelper
|
||||
return $path;
|
||||
}
|
||||
// the path may contain ".", ".." or double slashes, need to clean them up
|
||||
$parts = [];
|
||||
if (strpos($path, "{$ds}{$ds}") === 0 && $ds == '\\') {
|
||||
$parts = [$ds];
|
||||
} else {
|
||||
$parts = [];
|
||||
}
|
||||
foreach (explode($ds, $path) as $part) {
|
||||
if ($part === '..' && !empty($parts) && end($parts) !== '..') {
|
||||
array_pop($parts);
|
||||
|
@ -739,6 +739,12 @@ class FileHelperTest extends TestCase
|
||||
$this->assertEquals("..{$ds}a", FileHelper::normalizePath('././..\\a'));
|
||||
$this->assertEquals("..{$ds}a", FileHelper::normalizePath('./..\\a/../a'));
|
||||
$this->assertEquals("..{$ds}b", FileHelper::normalizePath('./..\\a/../b'));
|
||||
|
||||
// Windows file system may have paths for network shares that start with two backslashes
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx
|
||||
// https://github.com/yiisoft/yii2/issues/13034
|
||||
$this->assertEquals('\\\\server\share\path\file', FileHelper::normalizePath('\\\\server\share\path\file', '\\'));
|
||||
|
||||
}
|
||||
|
||||
public function testLocalizedDirectory()
|
||||
|
Reference in New Issue
Block a user