Changeset View
Changeset View
Standalone View
Standalone View
src/aphront/configuration/AphrontApplicationConfiguration.php
| Show First 20 Lines • Show All 806 Lines • ▼ Show 20 Lines | if ($request_method === 'PUT') { | ||||
| return; | return; | ||||
| } | } | ||||
| // For POST requests, we're going to read the raw input ourselves here | // For POST requests, we're going to read the raw input ourselves here | ||||
| // if we can. Among other things, this corrects variable names with | // if we can. Among other things, this corrects variable names with | ||||
| // the "." character in them, which PHP normally converts into "_". | // the "." character in them, which PHP normally converts into "_". | ||||
| // There are two major considerations here: whether the | // If "enable_post_data_reading" is on, the documentation suggests we | ||||
| // `enable_post_data_reading` option is set, and whether the content | // can not read the body. In practice, we seem to be able to. This may | ||||
| // type is "multipart/form-data" or not. | // need to be resolved at some point, likely by instructing installs | ||||
| // to disable this option. | |||||
| // If `enable_post_data_reading` is off, we're free to read the entire | |||||
| // raw request body and parse it -- and we must, because $_POST and | |||||
| // $_FILES are not built for us. If `enable_post_data_reading` is on, | |||||
| // which is the default, we may not be able to read the body (the | |||||
| // documentation says we can't, but empirically we can at least some | |||||
| // of the time). | |||||
| // If the content type is "multipart/form-data", we need to build both | // If the content type is "multipart/form-data", we need to build both | ||||
| // $_POST and $_FILES, which is involved. The body itself is also more | // $_POST and $_FILES, which is involved. The body itself is also more | ||||
| // difficult to parse than other requests. | // difficult to parse than other requests. | ||||
| $raw_input = PhabricatorStartup::getRawInput(); | $raw_input = PhabricatorStartup::getRawInput(); | ||||
| $parser = new PhutilQueryStringParser(); | $parser = new PhutilQueryStringParser(); | ||||
| if (strlen($raw_input)) { | if (strlen($raw_input)) { | ||||
| $content_type = idx($_SERVER, 'CONTENT_TYPE'); | $content_type = idx($_SERVER, 'CONTENT_TYPE'); | ||||
| $is_multipart = preg_match('@^multipart/form-data@i', $content_type); | $is_multipart = preg_match('@^multipart/form-data@i', $content_type); | ||||
| if ($is_multipart && !ini_get('enable_post_data_reading')) { | if ($is_multipart) { | ||||
| $multipart_parser = id(new AphrontMultipartParser()) | $multipart_parser = id(new AphrontMultipartParser()) | ||||
| ->setContentType($content_type); | ->setContentType($content_type); | ||||
| $multipart_parser->beginParse(); | $multipart_parser->beginParse(); | ||||
| $multipart_parser->continueParse($raw_input); | $multipart_parser->continueParse($raw_input); | ||||
| $parts = $multipart_parser->endParse(); | $parts = $multipart_parser->endParse(); | ||||
| // We're building and then parsing a query string so that requests | // We're building and then parsing a query string so that requests | ||||
| ▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines | |||||