Changeset View
Changeset View
Standalone View
Standalone View
src/parser/PhutilQueryStringParser.php
Context not available. | |||||
$list = $this->parseQueryStringToPairList($query_string); | $list = $this->parseQueryStringToPairList($query_string); | ||||
foreach ($list as $parts) { | foreach ($list as $parts) { | ||||
list($key, $value) = $parts; | list($key, $value) = $parts; | ||||
if (!strlen($key)) { | if (!@strlen($key)) { | ||||
continue; | continue; | ||||
} | } | ||||
$this->parseQueryKeyToArr($key, $value, $result); | $this->parseQueryKeyToArr($key, $value, $result); | ||||
Context not available. | |||||
public function parseQueryStringToPairList($query_string) { | public function parseQueryStringToPairList($query_string) { | ||||
$list = array(); | $list = array(); | ||||
if (!strlen($query_string)) { | if (!@strlen($query_string)) { | ||||
return $list; | return $list; | ||||
} | } | ||||
$pairs = explode('&', $query_string); | $pairs = @explode('&', $query_string); | ||||
foreach ($pairs as $pair) { | foreach ($pairs as $pair) { | ||||
if (!strlen($pair)) { | if (!@strlen($pair)) { | ||||
continue; | continue; | ||||
} | } | ||||
$parts = explode('=', $pair, 2); | $parts = @explode('=', $pair, 2); | ||||
if (count($parts) < 2) { | if (count($parts) < 2) { | ||||
$parts[] = ''; | $parts[] = ''; | ||||
} | } | ||||
Context not available. | |||||
* @param array $input_arr | * @param array $input_arr | ||||
*/ | */ | ||||
private function parseQueryKeyToArr($key, $val, array &$input_arr) { | private function parseQueryKeyToArr($key, $val, array &$input_arr) { | ||||
if (preg_match('/^[^\[\]]+(?:\[[^\[\]]*\])+$/', $key)) { | if (@preg_match('/^[^\[\]]+(?:\[[^\[\]]*\])+$/', $key)) { | ||||
$key_pieces = preg_split('/\]?\[/', rtrim($key, ']')); | $key_pieces = preg_split('/\]?\[/', rtrim($key, ']')); | ||||
if ($key_pieces) { | if ($key_pieces) { | ||||
$cursor = &$input_arr; | $cursor = &$input_arr; | ||||
foreach ($key_pieces as $piece) { | foreach ($key_pieces as $piece) { | ||||
if (strlen($piece)) { | if (@strlen($piece)) { | ||||
if (empty($cursor[$piece]) || !is_array($cursor[$piece])) { | if (empty($cursor[$piece]) || !is_array($cursor[$piece])) { | ||||
$cursor[$piece] = array(); | $cursor[$piece] = array(); | ||||
} | } | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0