From 308c4f2407543ae37abdf78653a1c7ea70d02c2a Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 12 Feb 2019 05:31:04 -0800 Subject: [PATCH] Fix "AphrontRequest->getRequestURI()" for requests with "x[]=1" parameters in the URI Summary: Ref T13250. See PHI1069. This is a small fix for `getRequestURI()` currently not working if the request includes "x[]=..." PHP-flavored array parameters, beacause they're parsed into arrays by `$_GET` and `setQueryParams(...)` no longer accepts nonscalars. Instead, just parse the raw request URI. Test Plan: Visited `/search/hovercard/?phids[]=X`, no more fatal. Dumped the resulting URI, saw it had the right value. Tried `?phids[]=x&x=1&x=1&x=1`, saw the parameters correctly preserved. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13250 Differential Revision: https://secure.phabricator.com/D20147 --- src/aphront/AphrontRequest.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/aphront/AphrontRequest.php b/src/aphront/AphrontRequest.php index 78e6dac9d3..a65566e867 100644 --- a/src/aphront/AphrontRequest.php +++ b/src/aphront/AphrontRequest.php @@ -591,10 +591,15 @@ final class AphrontRequest extends Phobject { } public function getRequestURI() { - $get = $_GET; - unset($get['__path__']); + $request_uri = idx($_SERVER, 'REQUEST_URI', '/'); + + $uri = new PhutilURI($request_uri); + $uri->setQueryParam('__path__', null); + $path = phutil_escape_uri($this->getPath()); - return id(new PhutilURI($path))->setQueryParams($get); + $uri->setPath($path); + + return $uri; } public function getAbsoluteRequestURI() {