Author: Nikita Popov (nikic)
Date: 2021-12-05T12:28:36+01:00

Commit: 
https://github.com/php/web-master/commit/610060b1e03b35fbb334c7628d34f8ae1d4569e6
Raw diff: 
https://github.com/php/web-master/commit/610060b1e03b35fbb334c7628d34f8ae1d4569e6.diff

Check for payload decoding failure

Try to get more information in this case.

Changed paths:
  M  public/github-webhook.php


Diff:

diff --git a/public/github-webhook.php b/public/github-webhook.php
index 065f707..2e217d9 100644
--- a/public/github-webhook.php
+++ b/public/github-webhook.php
@@ -327,8 +327,14 @@ function handle_push_mail($payload) {
 }
 
 $payload = json_decode($body);
-$repoName = $payload->repository->name;
+if ($payload === null) {
+    header("HTTP/1.1 400 Bad Request");
+    echo "Failed to decode payload: ", json_last_error_msg(), "\n";
+    echo "Body:\n", $body, "\n";
+    exit;
+}
 
+$repoName = $payload->repository->name;
 switch ($event) {
     case 'ping':
         break;

-- 
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to