mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 04:17:48 +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];
|
$raw = $matches[1];
|
||||||
$lastComma = -1;
|
$lastComma = -1;
|
||||||
$newParts = [];
|
$newParts = [];
|
||||||
$quoteType = null;
|
$inQuotes = false;
|
||||||
for($i = 0, $len = strlen($raw); $i <= $len; ++$i){
|
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));
|
$part = substr($raw, $lastComma + 1, $i - ($lastComma + 1));
|
||||||
if(trim($part) === ""){ //regular parts will have quotes or something else that makes them non-empty
|
if(trim($part) === ""){ //regular parts will have quotes or something else that makes them non-empty
|
||||||
$part = '""';
|
$part = '""';
|
||||||
@ -284,13 +284,13 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
|||||||
$newParts[] = $part;
|
$newParts[] = $part;
|
||||||
$lastComma = $i;
|
$lastComma = $i;
|
||||||
}elseif($raw[$i] === '"'){
|
}elseif($raw[$i] === '"'){
|
||||||
if($quoteType === null){
|
if(!$inQuotes){
|
||||||
$quoteType = $raw[$i];
|
$inQuotes = true;
|
||||||
}elseif($raw[$i] === $quoteType){
|
}else{
|
||||||
$backslashes = 0;
|
$backslashes = 0;
|
||||||
for(; $backslashes < $i && $raw[$i - $backslashes - 1] === "\\"; ++$backslashes){}
|
for(; $backslashes < $i && $raw[$i - $backslashes - 1] === "\\"; ++$backslashes){}
|
||||||
if(($backslashes % 2) === 0){ //unescaped quote
|
if(($backslashes % 2) === 0){ //unescaped quote
|
||||||
$quoteType = null;
|
$inQuotes = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user