mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
PlayerNetworkSessionAdapter: clean up leftovers from multi quote support for json decode
This commit is contained in:
parent
e1ddf90695
commit
889cd5e206
@ -274,9 +274,9 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
$raw = $matches[1];
|
||||
$lastComma = -1;
|
||||
$newParts = [];
|
||||
$quoteType = null;
|
||||
$inQuotes = false;
|
||||
for($i = 0, $len = strlen($raw); $i <= $len; ++$i){
|
||||
if($i === $len or ($raw[$i] === "," and $quoteType === null)){
|
||||
if($i === $len or ($raw[$i] === "," and !$inQuotes)){
|
||||
$part = substr($raw, $lastComma + 1, $i - ($lastComma + 1));
|
||||
if(trim($part) === ""){ //regular parts will have quotes or something else that makes them non-empty
|
||||
$part = '""';
|
||||
@ -284,13 +284,13 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
||||
$newParts[] = $part;
|
||||
$lastComma = $i;
|
||||
}elseif($raw[$i] === '"'){
|
||||
if($quoteType === null){
|
||||
$quoteType = $raw[$i];
|
||||
}elseif($raw[$i] === $quoteType){
|
||||
if(!$inQuotes){
|
||||
$inQuotes = true;
|
||||
}else{
|
||||
$backslashes = 0;
|
||||
for(; $backslashes < $i && $raw[$i - $backslashes - 1] === "\\"; ++$backslashes){}
|
||||
if(($backslashes % 2) === 0){ //unescaped quote
|
||||
$quoteType = null;
|
||||
$inQuotes = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user