1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 14:30:56 +01:00

Replace manual query string construction with "phutil_build_http_querystring()"

Summary: Now that we have a nice function for this, use it to simplify some code.

Test Plan: Ran through the Duo enroll workflow to make sure signing still works.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D20053
This commit is contained in:
epriestley 2019-01-28 19:29:24 -08:00
parent a24e6deb57
commit 1767b80654
4 changed files with 9 additions and 12 deletions

View file

@ -772,6 +772,11 @@ final class AphrontApplicationConfiguration
$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
// with arrays (like "x[]=apple&x[]=banana") work correctly. This also
// means we can't use "phutil_build_http_querystring()", since it
// can't build a query string with duplicate names.
$query_string = array(); $query_string = array();
foreach ($parts as $part) { foreach ($parts as $part) {
if (!$part->isVariable()) { if (!$part->isVariable()) {
@ -780,8 +785,7 @@ final class AphrontApplicationConfiguration
$name = $part->getName(); $name = $part->getName();
$value = $part->getVariableValue(); $value = $part->getVariableValue();
$query_string[] = rawurlencode($name).'='.rawurlencode($value);
$query_string[] = urlencode($name).'='.urlencode($value);
} }
$query_string = implode('&', $query_string); $query_string = implode('&', $query_string);
$post = $parser->parseQueryString($query_string); $post = $parser->parseQueryString($query_string);

View file

@ -504,10 +504,7 @@ final class PhabricatorDuoAuthFactor
$push_info = array( $push_info = array(
pht('Domain') => $this->getInstallDisplayName(), pht('Domain') => $this->getInstallDisplayName(),
); );
foreach ($push_info as $k => $v) { $push_info = phutil_build_http_querystring($push_info);
$push_info[$k] = rawurlencode($k).'='.rawurlencode($v);
}
$push_info = implode('&', $push_info);
$parameters = array( $parameters = array(
'username' => $duo_user, 'username' => $duo_user,

View file

@ -91,11 +91,7 @@ final class PhabricatorDuoFuture
$http_method = $this->getHTTPMethod(); $http_method = $this->getHTTPMethod();
ksort($data); ksort($data);
$data_parts = array(); $data_parts = phutil_build_http_querystring($data);
foreach ($data as $key => $value) {
$data_parts[] = rawurlencode($key).'='.rawurlencode($value);
}
$data_parts = implode('&', $data_parts);
$corpus = array( $corpus = array(
$date, $date,

View file

@ -528,7 +528,7 @@ final class DiffusionServeController extends DiffusionController {
unset($query_data[$key]); unset($query_data[$key]);
} }
} }
$query_string = http_build_query($query_data, '', '&'); $query_string = phutil_build_http_querystring($query_data);
// We're about to wipe out PATH with the rest of the environment, so // We're about to wipe out PATH with the rest of the environment, so
// resolve the binary first. // resolve the binary first.