Prevent decrypt error for #859

This commit is contained in:
the-djmaze 2023-02-03 12:30:46 +01:00
parent b182372b83
commit c4df524a06
2 changed files with 11 additions and 4 deletions

View file

@ -91,9 +91,11 @@ abstract class AbstractConfig implements \JsonSerializable
public function getDecrypted(string $sSection, string $sName, $mDefault = null)
{
// $salt = \basename($this->sFile) not possible due to RainLoop\Plugins\Property
return isset($this->aData[$sSection][$sName][0])
? \SnappyMail\Crypt::DecryptFromJSON($this->aData[$sSection][$sName][0], \APP_SALT)
: $mDefault;
if (!empty($this->aData[$sSection][$sName][0])) try {
return \SnappyMail\Crypt::DecryptFromJSON($this->aData[$sSection][$sName][0], \APP_SALT);
} catch (\Throwable $e) {
}
return $mDefault;
}
public function setEncrypted(string $sSectionKey, string $sParamKey, $mParamValue) : void

View file

@ -187,9 +187,14 @@ class Property implements \JsonSerializable
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
$mValue = $this->mValue;
if ($this->encrypted && $mValue) try {
$mValue = \SnappyMail\Crypt::DecryptFromJSON($mValue, \APP_SALT);
} catch (\Throwable $e) {
}
return array(
'@Object' => 'Object/PluginProperty',
'value' => $this->encrypted ? \SnappyMail\Crypt::DecryptFromJSON($this->mValue, \APP_SALT) : $this->mValue,
'value' => $mValue,
'placeholder' => $this->sPlaceholder,
'name' => $this->sName,
'type' => $this->iType,