{"action":"created","comment":{"url":"https://api.github.com/repos/google/go-github/pulls/comments/134102384","pull_request_review_id":57359938,"id":134102384,"diff_hunk":"@@ -132,17 +137,37 @@ func messageMAC(signature string) ([]byte, func() hash.Hash, error) {\n //       // Process payload...\n //     }\n //\n-func ValidatePayload(r *http.Request, secretKey []byte) (payload []byte, err error) {\n-\tpayload, err = ioutil.ReadAll(r.Body)\n-\tif err != nil {\n-\t\treturn nil, err\n+func ValidatePayload(r *http.Request, secretKey []byte) ([]byte, error) {\n+\t// jsonPayload is the json webhook data\n+\tvar jsonPayload []byte\n+\t// rawPayload is the raw body that GitHub uses to calculate the signature\n+\tvar rawPayload []byte\n+\n+\tif r.Header.Get(\"Content-Type\") == \"application/x-www-form-urlencoded\" {","path":"github/messages.go","position":null,"original_position":40,"commit_id":"80460342270ae5ed8551803e5d915c522084e099","original_commit_id":"a4671234835b6afee72236be3938bf170cc2f8ff","user":{"login":"shurcooL","id":1924134,"avatar_url":"https://avatars3.githubusercontent.com/u/1924134?v=4","gravatar_id":"","url":"https://api.github.com/users/shurcooL","html_url":"https://github.com/shurcooL","followers_url":"https://api.github.com/users/shurcooL/followers","following_url":"https://api.github.com/users/shurcooL/following{/other_user}","gists_url":"https://api.github.com/users/shurcooL/gists{/gist_id}","starred_url":"https://api.github.com/users/shurcooL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shurcooL/subscriptions","organizations_url":"https://api.github.com/users/shurcooL/orgs","repos_url":"https://api.github.com/users/shurcooL/repos","events_url":"https://api.github.com/users/shurcooL/events{/privacy}","received_events_url":"https://api.github.com/users/shurcooL/received_events","type":"User","site_admin":false},"body":"I think that's fine, because GitHub will always be setting that header.","created_at":"2017-08-19T22:48:13Z","updated_at":"2017-08-19T22:48:13Z","html_url":"https://github.com/google/go-github/pull/693#discussion_r134102384","pull_request_url":"https://api.github.com/repos/google/go-github/pulls/693","_links":{"self":{"href":"https://api.github.com/repos/google/go-github/pulls/comments/134102384"},"html":{"href":"https://github.com/google/go-github/pull/693#discussion_r134102384"},"pull_request":{"href":"https://api.github.com/repos/google/go-github/pulls/693"}}},"pull_request":{"url":"https://api.github.com/repos/google/go-github/pulls/693","id":135739848,"html_url":"https://github.com/google/go-github/pull/693","diff_url":"https://github.com/google/go-github/pull/693.diff","patch_url":"https://github.com/google/go-github/pull/693.patch","issue_url":"https://api.github.com/repos/google/go-github/issues/693","number":693,"state":"open","locked":false,"title":"Accept application/x-www-form-urlencoded webhooks","user":{"login":"lkysow","id":1034429,"avatar_url":"https://avatars1.githubusercontent.com/u/1034429?v=4","gravatar_id":"","url":"https://api.github.com/users/lkysow","html_url":"https://github.com/lkysow","followers_url":"https://api.github.com/users/lkysow/followers","following_url":"https://api.github.com/users/lkysow/following{/other_user}","gists_url":"https://api.github.com/users/lkysow/gists{/gist_id}","starred_url":"https://api.github.com/users/lkysow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lkysow/subscriptions","organizations_url":"https://api.github.com/users/lkysow/orgs","repos_url":"https://api.github.com/users/lkysow/repos","events_url":"https://api.github.com/users/lkysow/events{/privacy}","received_events_url":"https://api.github.com/users/lkysow/received_events","type":"User","site_admin":false},"body":"- Enable `ValidatePayload` to work for webhooks with Content-Type `application/x-www-form-urlencoded` in addition to `application/json`.\r\n- Ensure `Body` is closed.\r\n- Reject any Content-Type that is not `application/x-www-form-urlencoded` or `application/json`.","created_at":"2017-08-15T06:02:04Z","updated_at":"2017-08-19T22:48:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"471817be3bed63650ae0a46807723f53ee03ea87","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/go-github/pulls/693/commits","review_comments_url":"https://api.github.com/repos/google/go-github/pulls/693/comments","review_comment_url":"https://api.github.com/repos/google/go-github/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/go-github/issues/693/comments","statuses_url":"https://api.github.com/repos/google/go-github/statuses/80460342270ae5ed8551803e5d915c522084e099","head":{"label":"lkysow:webhook-form","ref":"webhook-form","sha":"80460342270ae5ed8551803e5d915c522084e099","user":{"login":"lkysow","id":1034429,"avatar_url":"https://avatars1.githubusercontent.com/u/1034429?v=4","gravatar_id":"","url":"https://api.github.com/users/lkysow","html_url":"https://github.com/lkysow","followers_url":"https://api.github.com/users/lkysow/followers","following_url":"https://api.github.com/users/lkysow/following{/other_user}","gists_url":"https://api.github.com/users/lkysow/gists{/gist_id}","starred_url":"https://api.github.com/users/lkysow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lkysow/subscriptions","organizations_url":"https://api.github.com/users/lkysow/orgs","repos_url":"https://api.github.com/users/lkysow/repos","events_url":"https://api.github.com/users/lkysow/events{/privacy}","received_events_url":"https://api.github.com/users/lkysow/received_events","type":"User","site_admin":false},"repo":{"id":100343979,"name":"go-github","full_name":"lkysow/go-github","owner":{"login":"lkysow","id":1034429,"avatar_url":"https://avatars1.githubusercontent.com/u/1034429?v=4","gravatar_id":"","url":"https://api.github.com/users/lkysow","html_url":"https://github.com/lkysow","followers_url":"https://api.github.com/users/lkysow/followers","following_url":"https://api.github.com/users/lkysow/following{/other_user}","gists_url":"https://api.github.com/users/lkysow/gists{/gist_id}","starred_url":"https://api.github.com/users/lkysow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lkysow/subscriptions","organizations_url":"https://api.github.com/users/lkysow/orgs","repos_url":"https://api.github.com/users/lkysow/repos","events_url":"https://api.github.com/users/lkysow/events{/privacy}","received_events_url":"https://api.github.com/users/lkysow/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lkysow/go-github","description":"Go library for accessing the GitHub API","fork":true,"url":"https://api.github.com/repos/lkysow/go-github","forks_url":"https://api.github.com/repos/lkysow/go-github/forks","keys_url":"https://api.github.com/repos/lkysow/go-github/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lkysow/go-github/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lkysow/go-github/teams","hooks_url":"https://api.github.com/repos/lkysow/go-github/hooks","issue_events_url":"https://api.github.com/repos/lkysow/go-github/issues/events{/number}","events_url":"https://api.github.com/repos/lkysow/go-github/events","assignees_url":"https://api.github.com/repos/lkysow/go-github/assignees{/user}","branches_url":"https://api.github.com/repos/lkysow/go-github/branches{/branch}","tags_url":"https://api.github.com/repos/lkysow/go-github/tags","blobs_url":"https://api.github.com/repos/lkysow/go-github/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lkysow/go-github/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lkysow/go-github/git/refs{/sha}","trees_url":"https://api.github.com/repos/lkysow/go-github/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lkysow/go-github/statuses/{sha}","languages_url":"https://api.github.com/repos/lkysow/go-github/languages","stargazers_url":"https://api.github.com/repos/lkysow/go-github/stargazers","contributors_url":"https://api.github.com/repos/lkysow/go-github/contributors","subscribers_url":"https://api.github.com/repos/lkysow/go-github/subscribers","subscription_url":"https://api.github.com/repos/lkysow/go-github/subscription","commits_url":"https://api.github.com/repos/lkysow/go-github/commits{/sha}","git_commits_url":"https://api.github.com/repos/lkysow/go-github/git/commits{/sha}","comments_url":"https://api.github.com/repos/lkysow/go-github/comments{/number}","issue_comment_url":"https://api.github.com/repos/lkysow/go-github/issues/comments{/number}","contents_url":"https://api.github.com/repos/lkysow/go-github/contents/{+path}","compare_url":"https://api.github.com/repos/lkysow/go-github/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lkysow/go-github/merges","archive_url":"https://api.github.com/repos/lkysow/go-github/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lkysow/go-github/downloads","issues_url":"https://api.github.com/repos/lkysow/go-github/issues{/number}","pulls_url":"https://api.github.com/repos/lkysow/go-github/pulls{/number}","milestones_url":"https://api.github.com/repos/lkysow/go-github/milestones{/number}","notifications_url":"https://api.github.com/repos/lkysow/go-github/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lkysow/go-github/labels{/name}","releases_url":"https://api.github.com/repos/lkysow/go-github/releases{/id}","deployments_url":"https://api.github.com/repos/lkysow/go-github/deployments","created_at":"2017-08-15T05:59:34Z","updated_at":"2017-08-15T05:59:36Z","pushed_at":"2017-08-16T06:28:22Z","git_url":"git://github.com/lkysow/go-github.git","ssh_url":"git@github.com:lkysow/go-github.git","clone_url":"https://github.com/lkysow/go-github.git","svn_url":"https://github.com/lkysow/go-github","homepage":"http://godoc.org/github.com/google/go-github/github","size":1560,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"6afafa88c26eb51b33a8307c944bd2f0ef227af7","user":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":10270722,"name":"go-github","full_name":"google/go-github","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/go-github","description":"Go library for accessing the GitHub API","fork":false,"url":"https://api.github.com/repos/google/go-github","forks_url":"https://api.github.com/repos/google/go-github/forks","keys_url":"https://api.github.com/repos/google/go-github/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/go-github/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/go-github/teams","hooks_url":"https://api.github.com/repos/google/go-github/hooks","issue_events_url":"https://api.github.com/repos/google/go-github/issues/events{/number}","events_url":"https://api.github.com/repos/google/go-github/events","assignees_url":"https://api.github.com/repos/google/go-github/assignees{/user}","branches_url":"https://api.github.com/repos/google/go-github/branches{/branch}","tags_url":"https://api.github.com/repos/google/go-github/tags","blobs_url":"https://api.github.com/repos/google/go-github/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/go-github/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/go-github/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/go-github/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/go-github/statuses/{sha}","languages_url":"https://api.github.com/repos/google/go-github/languages","stargazers_url":"https://api.github.com/repos/google/go-github/stargazers","contributors_url":"https://api.github.com/repos/google/go-github/contributors","subscribers_url":"https://api.github.com/repos/google/go-github/subscribers","subscription_url":"https://api.github.com/repos/google/go-github/subscription","commits_url":"https://api.github.com/repos/google/go-github/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/go-github/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/go-github/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/go-github/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/go-github/contents/{+path}","compare_url":"https://api.github.com/repos/google/go-github/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/go-github/merges","archive_url":"https://api.github.com/repos/google/go-github/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/go-github/downloads","issues_url":"https://api.github.com/repos/google/go-github/issues{/number}","pulls_url":"https://api.github.com/repos/google/go-github/pulls{/number}","milestones_url":"https://api.github.com/repos/google/go-github/milestones{/number}","notifications_url":"https://api.github.com/repos/google/go-github/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/go-github/labels{/name}","releases_url":"https://api.github.com/repos/google/go-github/releases{/id}","deployments_url":"https://api.github.com/repos/google/go-github/deployments","created_at":"2013-05-24T16:42:58Z","updated_at":"2017-08-19T22:09:46Z","pushed_at":"2017-08-17T22:12:18Z","git_url":"git://github.com/google/go-github.git","ssh_url":"git@github.com:google/go-github.git","clone_url":"https://github.com/google/go-github.git","svn_url":"https://github.com/google/go-github","homepage":"http://godoc.org/github.com/google/go-github/github","size":1570,"stargazers_count":2812,"watchers_count":2812,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":664,"mirror_url":null,"open_issues_count":43,"forks":664,"open_issues":43,"watchers":2812,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/go-github/pulls/693"},"html":{"href":"https://github.com/google/go-github/pull/693"},"issue":{"href":"https://api.github.com/repos/google/go-github/issues/693"},"comments":{"href":"https://api.github.com/repos/google/go-github/issues/693/comments"},"review_comments":{"href":"https://api.github.com/repos/google/go-github/pulls/693/comments"},"review_comment":{"href":"https://api.github.com/repos/google/go-github/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/go-github/pulls/693/commits"},"statuses":{"href":"https://api.github.com/repos/google/go-github/statuses/80460342270ae5ed8551803e5d915c522084e099"}}}}
{"actor":{"display_login":"shurcooL"}}