From 01e5916bf33132958940f5981fd289530a8ec9ac Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Wed, 18 May 2022 23:43:29 +0200 Subject: [PATCH] Bugfix: Export contacts failed --- .../libraries/RainLoop/Actions/Contacts.php | 14 +++--- .../app/libraries/RainLoop/ServiceActions.php | 43 +++++++++++-------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Contacts.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Contacts.php index d3992f3dd..475f435d6 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Contacts.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Contacts.php @@ -297,10 +297,11 @@ trait Contacts \header('Accept-Ranges: none'); \header('Content-Transfer-Encoding: binary'); - $this->oHttp->ServerNoCache(); + $this->Http()->ServerNoCache(); - return $this->AddressBookProvider($oAccount)->IsActive() ? - $this->AddressBookProvider($oAccount)->Export($this->GetMainEmail($oAccount), 'vcf') : false; + $oAddressBookProvider = $this->AddressBookProvider($oAccount); + return $oAddressBookProvider->IsActive() ? + $oAddressBookProvider->Export($this->GetMainEmail($oAccount), 'vcf') : false; } public function RawContactsCsv() : bool @@ -312,10 +313,11 @@ trait Contacts \header('Accept-Ranges: none'); \header('Content-Transfer-Encoding: binary'); - $this->oHttp->ServerNoCache(); + $this->Http()->ServerNoCache(); - return $this->AddressBookProvider($oAccount)->IsActive() ? - $this->AddressBookProvider($oAccount)->Export($this->GetMainEmail($oAccount), 'csv') : false; + $oAddressBookProvider = $this->AddressBookProvider($oAccount); + return $oAddressBookProvider->IsActive() ? + $oAddressBookProvider->Export($this->GetMainEmail($oAccount), 'csv') : false; } private function importContactsFromVcfFile(\RainLoop\Model\Account $oAccount, /*resource*/ $rFile): int diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php index 5495b2a4d..3fd871e92 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/ServiceActions.php @@ -394,28 +394,33 @@ class ServiceActions try { $sRawError = 'Invalid action'; - if (0 !== \strlen($sAction)) + if (\strlen($sAction)) { - $sMethodName = 'Raw'.$sAction; - if (\method_exists($this->oActions, $sMethodName)) - { - \header('X-Raw-Action: '.$sMethodName); - \header('Content-Security-Policy: script-src \'none\'; child-src \'none\''); - - $sRawError = ''; - $this->oActions->SetActionParams(array( - 'RawKey' => empty($this->aPaths[3]) ? '' : $this->aPaths[3], - 'Params' => $this->aPaths - ), $sMethodName); - - if (!$this->oActions->{$sMethodName}()) + try { + $sMethodName = 'Raw'.$sAction; + if (\method_exists($this->oActions, $sMethodName)) { - $sRawError = 'False result'; + \header('X-Raw-Action: '.$sMethodName); + \header('Content-Security-Policy: script-src \'none\'; child-src \'none\''); + + $sRawError = ''; + $this->oActions->SetActionParams(array( + 'RawKey' => empty($this->aPaths[3]) ? '' : $this->aPaths[3], + 'Params' => $this->aPaths + ), $sMethodName); + + if (!$this->oActions->{$sMethodName}()) + { + $sRawError = 'False result'; + } } - } - else - { - $sRawError = 'Unknown action "'.$sAction.'"'; + else + { + $sRawError = 'Unknown action "'.$sAction.'"'; + } + } catch (\Throwable $e) { +// error_log(print_r($e,1)); + $sRawError = $e->getMessage(); } } else