Bugfix: Config used invalid gettype() values

This commit is contained in:
djmaze 2020-12-02 11:55:54 +01:00
parent 755fcf43b7
commit 2b8c259fe3
2 changed files with 67 additions and 70 deletions

View file

@ -74,21 +74,20 @@ abstract class AbstractConfig
{ {
if (isset($this->aData[$sSectionKey][$sParamKey][0])) if (isset($this->aData[$sSectionKey][$sParamKey][0]))
{ {
$sType = \gettype($this->aData[$sSectionKey][$sParamKey][0]); switch (\gettype($this->aData[$sSectionKey][$sParamKey][0]))
switch ($sType)
{ {
default: case 'boolean':
case 'float': $this->aData[$sSectionKey][$sParamKey][0] = (bool) $mParamValue;
case 'string': break;
$this->aData[$sSectionKey][$sParamKey][0] = (string) $mParamValue; case 'double':
$this->aData[$sSectionKey][$sParamKey][0] = (float) $mParamValue;
break; break;
case 'int':
case 'integer': case 'integer':
$this->aData[$sSectionKey][$sParamKey][0] = (int) $mParamValue; $this->aData[$sSectionKey][$sParamKey][0] = (int) $mParamValue;
break; break;
case 'bool': case 'string':
case 'boolean': default:
$this->aData[$sSectionKey][$sParamKey][0] = (bool) $mParamValue; $this->aData[$sSectionKey][$sParamKey][0] = (string) $mParamValue;
break; break;
} }
} }
@ -275,17 +274,16 @@ abstract class AbstractConfig
$sValue = '""'; $sValue = '""';
switch (\gettype($mParamValue[0])) switch (\gettype($mParamValue[0]))
{ {
default: case 'boolean':
case 'string': $sValue = $mParamValue[0] ? 'On' : 'Off';
$sValue = '"'.\str_replace('"', '\"', $mParamValue[0]).'"';
break; break;
case 'int': case 'double':
case 'integer': case 'integer':
$sValue = $mParamValue[0]; $sValue = $mParamValue[0];
break; break;
case 'bool': case 'string':
case 'boolean': default:
$sValue = $mParamValue[0] ? 'On' : 'Off'; $sValue = '"'.\str_replace('"', '\\"', $mParamValue[0]).'"';
break; break;
} }

View file

@ -125,10 +125,9 @@ class Application extends \RainLoop\Config\AbstractConfig
'allow_additional_accounts' => array(true, ''), 'allow_additional_accounts' => array(true, ''),
'allow_additional_identities' => array(true, ''), 'allow_additional_identities' => array(true, ''),
'messages_per_page' => array(20, ' Number of messages displayed on page by default'), 'messages_per_page' => array(20, 'Number of messages displayed on page by default'),
'attachment_size_limit' => array(25, 'attachment_size_limit' => array(25, 'File size limit (MB) for file upload on compose screen
'File size limit (MB) for file upload on compose screen
0 for unlimited.') 0 for unlimited.')
), ),