mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Implement PhutilRequest parser #2
Summary: D6278 kind of got closed and commited, this is the actual direction. Ref T3432 Depends on D6277 Test Plan: Keep using the site Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin, mbishopim3 Maniphest Tasks: T3432 Differential Revision: https://secure.phabricator.com/D6283
This commit is contained in:
parent
d0da409eb0
commit
b26549b5fa
4 changed files with 32 additions and 9 deletions
|
@ -81,10 +81,27 @@ class AphrontDefaultApplicationConfiguration
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phutil-external-symbol class PhabricatorStartup
|
||||||
|
*/
|
||||||
public function buildRequest() {
|
public function buildRequest() {
|
||||||
|
$parser = new PhutilQueryStringParser();
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
$raw_input = PhabricatorStartup::getRawInput();
|
||||||
|
if (strlen($raw_input)) {
|
||||||
|
$data += $parser->parseQueryString($raw_input);
|
||||||
|
} else if ($_POST) {
|
||||||
|
$data += $_POST;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data += $parser->parseQueryString(
|
||||||
|
isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : "");
|
||||||
|
|
||||||
$request = new AphrontRequest($this->getHost(), $this->getPath());
|
$request = new AphrontRequest($this->getHost(), $this->getPath());
|
||||||
$request->setRequestData($_POST + $_GET);
|
$request->setRequestData($data);
|
||||||
$request->setApplicationConfiguration($this);
|
$request->setApplicationConfiguration($this);
|
||||||
|
|
||||||
return $request;
|
return $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
final class PhabricatorFileDropUploadController
|
final class PhabricatorFileDropUploadController
|
||||||
extends PhabricatorFileController {
|
extends PhabricatorFileController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @phutil-external-symbol class PhabricatorStartup
|
||||||
|
*/
|
||||||
public function processRequest() {
|
public function processRequest() {
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$user = $request->getUser();
|
$user = $request->getUser();
|
||||||
|
@ -10,7 +13,7 @@ final class PhabricatorFileDropUploadController
|
||||||
// NOTE: Throws if valid CSRF token is not present in the request.
|
// NOTE: Throws if valid CSRF token is not present in the request.
|
||||||
$request->validateCSRF();
|
$request->validateCSRF();
|
||||||
|
|
||||||
$data = file_get_contents('php://input');
|
$data = PhabricatorStartup::getRawInput();
|
||||||
$name = $request->getStr('name');
|
$name = $request->getStr('name');
|
||||||
|
|
||||||
$file = PhabricatorFile::newFromXHRUpload(
|
$file = PhabricatorFile::newFromXHRUpload(
|
||||||
|
|
|
@ -18,6 +18,7 @@ final class PhabricatorStartup {
|
||||||
private static $startTime;
|
private static $startTime;
|
||||||
private static $globals = array();
|
private static $globals = array();
|
||||||
private static $capturingOutput;
|
private static $capturingOutput;
|
||||||
|
private static $rawInput;
|
||||||
|
|
||||||
|
|
||||||
/* -( Accessing Request Information )-------------------------------------- */
|
/* -( Accessing Request Information )-------------------------------------- */
|
||||||
|
@ -61,6 +62,13 @@ final class PhabricatorStartup {
|
||||||
return self::$globals[$key];
|
return self::$globals[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @task info
|
||||||
|
*/
|
||||||
|
public static function getRawInput() {
|
||||||
|
return self::$rawInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( Startup Hooks )------------------------------------------------------ */
|
/* -( Startup Hooks )------------------------------------------------------ */
|
||||||
|
|
||||||
|
@ -89,6 +97,8 @@ final class PhabricatorStartup {
|
||||||
self::detectPostMaxSizeTriggered();
|
self::detectPostMaxSizeTriggered();
|
||||||
|
|
||||||
self::beginOutputCapture();
|
self::beginOutputCapture();
|
||||||
|
|
||||||
|
self::$rawInput = (string)file_get_contents('php://input');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,13 +34,6 @@ try {
|
||||||
$host = AphrontRequest::getHTTPHeader('Host');
|
$host = AphrontRequest::getHTTPHeader('Host');
|
||||||
$path = $_REQUEST['__path__'];
|
$path = $_REQUEST['__path__'];
|
||||||
|
|
||||||
$parser = new PhutilQueryStringParser();
|
|
||||||
$_GET = $parser->parseQueryString(
|
|
||||||
isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : "");
|
|
||||||
$_POST = $parser->parseQueryString(
|
|
||||||
(string)file_get_contents('php://input'));
|
|
||||||
$_REQUEST = $_POST + $_GET;
|
|
||||||
|
|
||||||
switch ($host) {
|
switch ($host) {
|
||||||
default:
|
default:
|
||||||
$config_key = 'aphront.default-application-configuration-class';
|
$config_key = 'aphront.default-application-configuration-class';
|
||||||
|
|
Loading…
Reference in a new issue