Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Allow escape for period in config nested keys #3525

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/pocketmine/utils/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,18 @@ public function __unset($k){
* @param $value
*/
public function setNested($key, $value){
$vars = explode(".", $key);
$vars = [];
$current = "";
foreach(explode(".", $key) as $var){
if(substr($var, -1) === "\\"){
$current .= $var . ".";
}else{
$var = $current . $var;
$current = "";
$vars[] = $var;
}
}

$base = array_shift($vars);

if(!isset($this->config[$base])){
Expand Down Expand Up @@ -291,7 +302,18 @@ public function getNested($key, $default = null){
return $this->nestedCache[$key];
}

$vars = explode(".", $key);
$vars = [];
$current = "";
foreach(explode(".", $key) as $var){
if(substr($var, -1) === "\\"){
$current .= $var . ".";
}else{
$var = $current . $var;
$current = "";
$vars[] = $var;
}
}

$base = array_shift($vars);
if(isset($this->config[$base])){
$base = $this->config[$base];
Expand Down