diff --git a/lib/Config/Initializer.php b/lib/Config/Initializer.php index c21c8c3a6b..f771938685 100644 --- a/lib/Config/Initializer.php +++ b/lib/Config/Initializer.php @@ -172,8 +172,12 @@ class Initializer { } function setupPublicAPI() { - $publicAPI = new PublicAPI(); - $publicAPI->init(); + try { + $publicAPI = new PublicAPI(); + $publicAPI->init(); + } catch(\Exception $e) { + // continue execution + } } function runQueueSupervisor() { diff --git a/lib/Config/PublicAPI.php b/lib/Config/PublicAPI.php index 35f6466474..71e21a005c 100644 --- a/lib/Config/PublicAPI.php +++ b/lib/Config/PublicAPI.php @@ -25,13 +25,11 @@ class PublicAPI { $this->action = isset($_GET['action']) ? Helpers::underscoreToCamelCase($_GET['action']) : false; - $this->data = isset($_GET['data']) ? - unserialize(base64_decode($_GET['data'])) : - false; + $this->data = $this->getAndValidateData(); } function init() { - if(!$this->api && !$this->endpoint) return; + if(!$this->api || !$this->endpoint) return; $this->_checkAndCallMethod($this, $this->endpoint, $terminate_request = true); } @@ -74,4 +72,13 @@ class PublicAPI { ) ); } + + function getAndValidateData() { + if (!isset($_GET['data'])) return false; + $data = base64_decode($_GET['data']); + if (!is_serialized($data)) { + throw new \Exception(__('Invalid data format.')); + } + return unserialize($data); + } } \ No newline at end of file