Skip to content

Commit

Permalink
Make script treat headers in case-insensitive way
Browse files Browse the repository at this point in the history
  • Loading branch information
dintel committed Jul 22, 2015
1 parent 89353b2 commit 461636a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dintel/php-github-webhook",
"description": "Simple class for handling GitHub webhook calls",
"version": "0.1.0",
"version": "0.1.1",
"keywords": ["git","webhook"],
"license": "BSD-3-Clause",
"authors": [
Expand Down
14 changes: 10 additions & 4 deletions src/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,22 @@ public function handle()

public function validate()
{
$headers = apache_request_headers();
$signature = @$_SERVER['HTTP_X_HUB_SIGNATURE'];
$event = @$_SERVER['HTTP_X_GITHUB_EVENT'];
$delivery = @$_SERVER['HTTP_X_GITHUB_DELIVERY'];
$payload = file_get_contents('php://input');

if (!$this->validateSignature($headers['X-Hub-Signature'], $payload)) {
if (!isset($signature, $event, $delivery)) {
return false;
}

if (!$this->validateSignature($signature, $payload)) {
return false;
}

$this->data = json_decode($payload,true);
$this->event = $headers['X-GitHub-Event'];
$this->delivery = $headers['X-GitHub-Delivery'];
$this->event = $event;
$this->delivery = $delivery;
return true;
}

Expand Down

0 comments on commit 461636a

Please sign in to comment.