From c4df524a0695f9f819f3c7ade8ff86ad702d0f8a Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Fri, 3 Feb 2023 12:30:46 +0100 Subject: [PATCH] Prevent decrypt error for #859 --- .../app/libraries/RainLoop/Config/AbstractConfig.php | 8 +++++--- .../v/0.0.0/app/libraries/RainLoop/Plugins/Property.php | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/AbstractConfig.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/AbstractConfig.php index 0e4ed05c2..483c165db 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/AbstractConfig.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/AbstractConfig.php @@ -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 diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Plugins/Property.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Plugins/Property.php index 62e2bdb12..8a6504ff4 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Plugins/Property.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Plugins/Property.php @@ -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,