From 00479d26cb79e3d075e287cf9d0d5d33ef9a2ab9 Mon Sep 17 00:00:00 2001 From: jitendrapurohit Date: Wed, 13 Apr 2016 18:45:54 +0530 Subject: [PATCH] CRM-18384 - fix event info urls to avoid link tracking issues CRM-18384 - decode incorrect keys in , when & is present in url --- CRM/Utils/Request.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/CRM/Utils/Request.php b/CRM/Utils/Request.php index c08f10b99b..a5357f85f3 100644 --- a/CRM/Utils/Request.php +++ b/CRM/Utils/Request.php @@ -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,26 @@ 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) { + // 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]; + unset($method[$key]); + } + } + return CRM_Utils_Array::value($name, $method); + } + /** * This is a replacement for $_REQUEST which includes $_GET/$_POST * but excludes $_COOKIE / $_ENV / $_SERVER. -- 2.25.1