From 9ded40ba9c6d928827efcb93ecbe56f0bbf6ce51 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 21 Nov 2023 00:13:22 +0100 Subject: [PATCH] Idea to prevent `exit` inside Nextcloud --- .../snappymail/lib/Controller/PageController.php | 8 ++++---- .../snappymail/lib/Util/SnappyMailHelper.php | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/integrations/nextcloud/snappymail/lib/Controller/PageController.php b/integrations/nextcloud/snappymail/lib/Controller/PageController.php index 470c2d78b..1c001954e 100644 --- a/integrations/nextcloud/snappymail/lib/Controller/PageController.php +++ b/integrations/nextcloud/snappymail/lib/Controller/PageController.php @@ -38,7 +38,7 @@ class PageController extends Controller SnappyMailHelper::loadApp(); $bAdmin = \RainLoop\Api::Config()->Get('security', 'admin_panel_key', 'admin') == $_SERVER['QUERY_STRING']; if (!$bAdmin) { - SnappyMailHelper::startApp(true); + return SnappyMailHelper::startApp(true); } } @@ -109,7 +109,7 @@ class PageController extends Controller */ public function appGet() { - SnappyMailHelper::startApp(true); + return SnappyMailHelper::startApp(true); } /** @@ -118,7 +118,7 @@ class PageController extends Controller */ public function appPost() { - SnappyMailHelper::startApp(true); + return SnappyMailHelper::startApp(true); } /** @@ -127,6 +127,6 @@ class PageController extends Controller */ public function indexPost() { - SnappyMailHelper::startApp(true); + return SnappyMailHelper::startApp(true); } } diff --git a/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php b/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php index d625a9c86..fa3fc5414 100644 --- a/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php +++ b/integrations/nextcloud/snappymail/lib/Util/SnappyMailHelper.php @@ -2,6 +2,19 @@ namespace OCA\SnappyMail\Util; +class SnappyMailResponse extends \OCP\AppFramework\Http\Response +{ + public function render(): string + { + $data = ''; + $i = \ob_get_level(); + while ($i--) { + $data .= \ob_get_clean(); + } + return $data; + } +} + class SnappyMailHelper { @@ -31,7 +44,7 @@ class SnappyMailHelper require_once $app_dir . '/index.php'; } - public static function startApp(bool $handle = false) : void + public static function startApp(bool $handle = false) { static::loadApp(); @@ -105,6 +118,7 @@ class SnappyMailHelper \RainLoop\Service::Handle(); // https://github.com/the-djmaze/snappymail/issues/1069 exit; +// return new SnappyMailResponse(); } } catch (\Throwable $e) { // Ignore login failure