diff options
| author | 2018-11-30 21:53:47 +0000 | |
|---|---|---|
| committer | 2018-11-30 21:53:47 +0000 | |
| commit | fcc3bdda6bf525fbeb2d4eb75729a3ca1ecff0a4 (patch) | |
| tree | 4b4cbafdfae89365e394066f6287903a294ba075 | |
| parent | rest_api.py's '_safe_handle' function isn't used and doesn't need to be used now (diff) | |
| signature | ||
Support form-encoded github webhook data
| -rw-r--r-- | modules/github.py | 8 |
1 files changed, 7 insertions, 1 deletions
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": |
