Merge commit '786f416f2ef31726b9e6fa0a5edde36aecddf085'

# Conflicts:
#	resources/vanilla
#	src/plugin/PluginBase.php
#	src/utils/Utils.php
This commit is contained in:
Dylan K. Taylor
2020-05-19 21:19:44 +01:00
4 changed files with 7 additions and 5 deletions

View File

@@ -42,6 +42,7 @@ use function str_replace;
use function stream_get_contents;
use function strpos;
use function unlink;
use const DIRECTORY_SEPARATOR;
use const LOCK_EX;
use const LOCK_NB;
use const LOCK_SH;
@@ -80,7 +81,7 @@ final class Filesystem{
* @return string
*/
public static function cleanPath($path){
$result = str_replace(["\\", ".php", "phar://"], ["/", "", ""], $path);
$result = str_replace([DIRECTORY_SEPARATOR, ".php", "phar://"], ["/", "", ""], $path);
//remove relative paths
//TODO: make these paths dynamic so they can be unit-tested against
@@ -89,7 +90,7 @@ final class Filesystem{
\pocketmine\PATH => ""
];
foreach($cleanPaths as $cleanPath => $replacement){
$cleanPath = rtrim(str_replace(["\\", "phar://"], ["/", ""], $cleanPath), "/");
$cleanPath = rtrim(str_replace([DIRECTORY_SEPARATOR, "phar://"], ["/", ""], $cleanPath), "/");
if(strpos($result, $cleanPath) === 0){
$result = ltrim(str_replace($cleanPath, $replacement, $result), "/");
}