I am creating a Phabricator application that acts as a callback endpoint for GitHub (and perhaps other) PubSub events.
The starting code is here: https://github.com/christopher-johnson/phabricator-extensions-pubsub
The way that it works is that a webhook is created in GitHub that subscribes a Phabricator project with a callback URL. The JSON formatted event payload is routed to a phabricator url with a project id (i.e.. http://phab09.wmflabs.org/pubsub/event/1).
The problem is that the PhutilQueryStringParser is mangling the JSON before it is saved in the requestData variable. I have fixed this with a few line change to AphrontDefaultApplicationConfiguration lines 32-43.
$jsonparser = new PhutilJSONParser(); $content_type = idx($_SERVER, 'CONTENT_TYPE'); $is_form_data = preg_match('@^multipart/form-data@i', $content_type); $is_json_data = preg_match('@^application/json@i', $content_type); $raw_input = PhabricatorStartup::getRawInput(); if (strlen($raw_input) && !$is_form_data && !$is_json_data) { $data += $parser->parseQueryString($raw_input); } else if ($is_json_data) { $data += $jsonparser->parse(urldecode($raw_input)); } else if ($_POST) { $data += $_POST; }
I am not sure that this is the best fix for this problem, but it really helps me with this use case. Please advise on how to proceed.