Skip to content

Commit f033570

Browse files
committed
Check to see if the SignedRequest headers are set before accessing
PHP Notices were issued if the request doesn't contain the expected headers. Now, null values are passed to loadFromArray(), where the values will fail validation.
1 parent b2afee4 commit f033570

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/MessageBird/Objects/SignedRequest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ public static function createFromGlobals()
5151
{
5252
$body = file_get_contents('php://input');
5353
$queryParameters = $_GET;
54-
$requestTimestamp = $_SERVER['HTTP_MESSAGEBIRD_REQUEST_TIMESTAMP'];
55-
$signature = $_SERVER['HTTP_MESSAGEBIRD_SIGNATURE'];
54+
$requestTimestamp = isset($_SERVER['HTTP_MESSAGEBIRD_REQUEST_TIMESTAMP']) ?
55+
$_SERVER['HTTP_MESSAGEBIRD_REQUEST_TIMESTAMP'] : null;
56+
$signature = isset($_SERVER['HTTP_MESSAGEBIRD_SIGNATURE']) ?
57+
$_SERVER['HTTP_MESSAGEBIRD_SIGNATURE'] : null;
5658

5759
$signedRequest = new SignedRequest();
5860
$signedRequest->loadFromArray(compact('body', 'queryParameters', 'requestTimestamp', 'signature'));

0 commit comments

Comments
 (0)