mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 21:41:19 +08:00
Fixes #17235: yii\helpers\FileHelper::normalizePath() now accepts stream wrappers
This commit is contained in:
committed by
Alexander Makarov
parent
e9b33916b6
commit
9c37016dac
@ -5,6 +5,7 @@ Yii Framework 2 Change Log
|
||||
------------------------
|
||||
|
||||
- Bug #17220: Fixed error when using non-InputWidget in active form field (s1lver)
|
||||
- Bug #17235: `yii\helpers\FileHelper::normalizePath()` now accepts stream wrappers (razvanphp)
|
||||
|
||||
|
||||
2.0.17 March 22, 2019
|
||||
|
||||
@ -50,6 +50,9 @@ class BaseFileHelper
|
||||
* - Turn multiple consecutive slashes into a single one (e.g. "/a///b/c" becomes "/a/b/c")
|
||||
* - Remove ".." and "." based on their meanings (e.g. "/a/./b/../c" becomes "/a/c")
|
||||
*
|
||||
* Note: For registered stream wrappers, the consecutive slashes rule
|
||||
* and ".."/"." translations are skipped.
|
||||
*
|
||||
* @param string $path the file/directory path to be normalized
|
||||
* @param string $ds the directory separator to be used in the normalized result. Defaults to `DIRECTORY_SEPARATOR`.
|
||||
* @return string the normalized file/directory path
|
||||
@ -60,6 +63,12 @@ class BaseFileHelper
|
||||
if (strpos($ds . $path, "{$ds}.") === false && strpos($path, "{$ds}{$ds}") === false) {
|
||||
return $path;
|
||||
}
|
||||
// fix #17235 stream wrappers
|
||||
foreach (stream_get_wrappers() as $protocol) {
|
||||
if (strpos($path, "{$protocol}://") === 0) {
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
// the path may contain ".", ".." or double slashes, need to clean them up
|
||||
if (strpos($path, "{$ds}{$ds}") === 0 && $ds == '\\') {
|
||||
$parts = [$ds];
|
||||
|
||||
Reference in New Issue
Block a user