4 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -772,6 +772,11 @@ private static function readHTTPPOSTData() {
772
772
$ multipart_parser ->continueParse ($ raw_input );
773
773
$ parts = $ multipart_parser ->endParse ();
774
774
775
+ // We're building and then parsing a query string so that requests
776
+ // with arrays (like "x[]=apple&x[]=banana") work correctly. This also
777
+ // means we can't use "phutil_build_http_querystring()", since it
778
+ // can't build a query string with duplicate names.
779
+
775
780
$ query_string = array ();
776
781
foreach ($ parts as $ part ) {
777
782
if (!$ part ->isVariable ()) {
@@ -780,8 +785,7 @@ private static function readHTTPPOSTData() {
780
785
781
786
$ name = $ part ->getName ();
782
787
$ value = $ part ->getVariableValue ();
783
-
784
- $ query_string [] = urlencode ($ name ).'= ' .urlencode ($ value );
788
+ $ query_string [] = rawurlencode ($ name ).'= ' .rawurlencode ($ value );
785
789
}
786
790
$ query_string = implode ('& ' , $ query_string );
787
791
$ post = $ parser ->parseQueryString ($ query_string );
Original file line number Diff line number Diff line change @@ -504,10 +504,7 @@ protected function newIssuedChallenges(
504
504
$ push_info = array (
505
505
pht ('Domain ' ) => $ this ->getInstallDisplayName (),
506
506
);
507
- foreach ($ push_info as $ k => $ v ) {
508
- $ push_info [$ k ] = rawurlencode ($ k ).'= ' .rawurlencode ($ v );
509
- }
510
- $ push_info = implode ('& ' , $ push_info );
507
+ $ push_info = phutil_build_http_querystring ($ push_info );
511
508
512
509
$ parameters = array (
513
510
'username ' => $ duo_user ,
Original file line number Diff line number Diff line change @@ -91,11 +91,7 @@ protected function getProxiedFuture() {
91
91
$ http_method = $ this ->getHTTPMethod ();
92
92
93
93
ksort ($ data );
94
- $ data_parts = array ();
95
- foreach ($ data as $ key => $ value ) {
96
- $ data_parts [] = rawurlencode ($ key ).'= ' .rawurlencode ($ value );
97
- }
98
- $ data_parts = implode ('& ' , $ data_parts );
94
+ $ data_parts = phutil_build_http_querystring ($ data );
99
95
100
96
$ corpus = array (
101
97
$ date ,
Original file line number Diff line number Diff line change @@ -528,7 +528,7 @@ private function serveGitRequest(
528
528
unset($ query_data [$ key ]);
529
529
}
530
530
}
531
- $ query_string = http_build_query ($ query_data, '' , ' & ' );
531
+ $ query_string = phutil_build_http_querystring ($ query_data );
532
532
533
533
// We're about to wipe out PATH with the rest of the environment, so
534
534
// resolve the binary first.
0 commit comments