X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FRequest.php;h=2748e07d7df8e2c16d361009ff96d2e1a6f7ae9e;hb=1e1ed556e29f820a3834d8b1d45e979bca8c720f;hp=c08f10b99ba1a198d0b223d1d92d95fa56f06bd9;hpb=2078a04eb10e9a0d655ea6dfa6c8d02615f0aefe;p=civicrm-core.git diff --git a/CRM/Utils/Request.php b/CRM/Utils/Request.php index c08f10b99b..2748e07d7d 100644 --- a/CRM/Utils/Request.php +++ b/CRM/Utils/Request.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2016 | + | Copyright CiviCRM LLC (c) 2004-2017 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -28,7 +28,7 @@ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2016 + * @copyright CiviCRM LLC (c) 2004-2017 */ /** @@ -94,15 +94,15 @@ class CRM_Utils_Request { $value = NULL; switch ($method) { case 'GET': - $value = CRM_Utils_Array::value($name, $_GET); + $value = self::getValue($name, $_GET); break; case 'POST': - $value = CRM_Utils_Array::value($name, $_POST); + $value = self::getValue($name, $_POST); break; default: - $value = CRM_Utils_Array::value($name, $_REQUEST); + $value = self::getValue($name, $_REQUEST); break; } @@ -136,6 +136,34 @@ class CRM_Utils_Request { return $value; } + /** + * @param string $name + * Name of the variable to be retrieved. + * + * @param array $method - '$_GET', '$_POST' or '$_REQUEST'. + * + * @return mixed + * The value of the variable + */ + public static function getValue($name, $method) { + if (isset($method[$name])) { + return $method[$name]; + } + // CRM-18384 - decode incorrect keys generated when & is present in url + foreach ($method as $key => $value) { + if (strpos($key, 'amp;') !== FALSE) { + $method[str_replace('amp;', '', $key)] = $method[$key]; + if (isset($method[$name])) { + return $method[$name]; + } + else { + continue; + } + } + } + return NULL; + } + /** * This is a replacement for $_REQUEST which includes $_GET/$_POST * but excludes $_COOKIE / $_ENV / $_SERVER.