PlayerNetworkSessionAdapter: clean up leftovers from multi quote support for json decode

This commit is contained in:
Dylan K. Taylor 2020-02-05 20:45:13 +00:00
parent e1ddf90695
commit 889cd5e206

View File

@ -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;
}
}
}