From fcc3bdda6bf525fbeb2d4eb75729a3ca1ecff0a4 Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 30 Nov 2018 21:53:47 +0000 Subject: Support form-encoded github webhook data --- modules/github.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'modules/github.py') diff --git a/modules/github.py b/modules/github.py index 36a04f0b..4a60a2eb 100644 --- a/modules/github.py +++ b/modules/github.py @@ -1,6 +1,8 @@ import itertools, json from src import ModuleManager, utils +FORM_ENCODED = "application/x-www-form-urlencoded" + COMMIT_URL = "https://github.com/%s/commit/%s" COMMIT_RANGE_URL = "https://github.com/%s/compare/%s...%s" CREATE_URL = "https://github.com/%s/tree/%s" @@ -33,7 +35,11 @@ COMMENT_ACTIONS = { class Module(ModuleManager.BaseModule): @utils.hook("api.post.github") def github(self, event): - data = json.loads(event["data"].decode("utf8")) + payload = event["data"].decode("utf8") + if event["headers"]["content-type"] == FORM_ENCODED: + payload = urllib.parse.parse_qs(urllib.parse.unquote(payload) + )["payload"][0] + data = json.loads(payload) github_event = event["headers"]["X-GitHub-Event"] if github_event == "ping": -- cgit v1.3.1-10-gc9f91