mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 03:47:16 +00:00
Improved support for paths with backslashes on Unix filesystems (#3501)
Fixes #3497
This commit is contained in:
parent
a67d2ae978
commit
786f416f2e
@ -78,8 +78,8 @@ abstract class PluginBase implements Plugin{
|
||||
$this->loader = $loader;
|
||||
$this->server = $server;
|
||||
$this->description = $description;
|
||||
$this->dataFolder = rtrim($dataFolder, "\\/") . "/";
|
||||
$this->file = rtrim($file, "\\/") . "/";
|
||||
$this->dataFolder = rtrim($dataFolder, "/" . DIRECTORY_SEPARATOR) . "/";
|
||||
$this->file = rtrim($file, "/" . DIRECTORY_SEPARATOR) . "/";
|
||||
$this->configFile = $this->dataFolder . "config.yml";
|
||||
$this->logger = new PluginLogger($this);
|
||||
$this->scheduler = new TaskScheduler($this->logger, $this->getFullName());
|
||||
@ -169,7 +169,7 @@ abstract class PluginBase implements Plugin{
|
||||
* @return null|resource Resource data, or null
|
||||
*/
|
||||
public function getResource(string $filename){
|
||||
$filename = rtrim(str_replace("\\", "/", $filename), "/");
|
||||
$filename = rtrim(str_replace(DIRECTORY_SEPARATOR, "/", $filename), "/");
|
||||
if(file_exists($this->file . "resources/" . $filename)){
|
||||
return fopen($this->file . "resources/" . $filename, "rb");
|
||||
}
|
||||
|
@ -89,6 +89,7 @@ use function substr;
|
||||
use function sys_get_temp_dir;
|
||||
use function trim;
|
||||
use function xdebug_get_function_stack;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const PHP_EOL;
|
||||
use const PHP_INT_MAX;
|
||||
use const PHP_INT_SIZE;
|
||||
@ -639,7 +640,7 @@ class Utils{
|
||||
* @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
|
||||
@ -648,7 +649,7 @@ class Utils{
|
||||
\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), "/");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user