From c80e2dbff932c8e25e752834369bca652f5f5f97 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 29 Nov 2015 19:12:32 -0500 Subject: [PATCH] D8 - Fix url function --- CRM/Utils/System.php | 28 ++++++++++++++++++++++++---- CRM/Utils/System/Base.php | 1 - CRM/Utils/System/Drupal8.php | 4 ---- CRM/Utils/System/DrupalBase.php | 3 +-- CRM/Utils/System/Joomla.php | 3 +-- CRM/Utils/System/WordPress.php | 3 +-- 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 74a1f8e092..7bf8bcfe28 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -269,13 +269,33 @@ class CRM_Utils_System { ) { $query = self::makeQueryString($query); - // we have a valid query and it has not yet been transformed - if ($htmlize && !empty($query) && strpos($query, '&') === FALSE) { - $query = htmlentities($query); + // Legacy handling for when the system passes around html escaped strings + if (strstr($query, '&')) { + $query = html_entity_decode($query); + } + + // Extract fragment from path or query if munged together + if ($query && strstr($query, '#')) { + list($path, $fragment) = explode('#', $query); + } + if ($path && strstr($path, '#')) { + list($path, $fragment) = explode('#', $path); + } + + // Extract query from path if munged together + if ($path && strstr($path, '?')) { + list($path, $extraQuery) = explode('?', $path); + $query = $extraQuery . ($query ? "&$query" : ''); } $config = CRM_Core_Config::singleton(); - return $config->userSystem->url($path, $query, $absolute, $fragment, $htmlize, $frontend, $forceBackend); + $url = $config->userSystem->url($path, $query, $absolute, $fragment, $frontend, $forceBackend); + + if ($htmlize) { + $url = htmlentities($url); + } + + return $url; } /** diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 2e5619b864..b79e51addc 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -132,7 +132,6 @@ abstract class CRM_Utils_System_Base { $query = NULL, $absolute = FALSE, $fragment = NULL, - $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE ) { diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index 4592ef3593..32a5bc4884 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -328,7 +328,6 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { $query = '', $absolute = FALSE, $fragment = NULL, - $htmlize = FALSE, $frontend = FALSE, $forceBackend = FALSE ) { @@ -357,9 +356,6 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { $url = urldecode($url); } - if ($htmlize) { - $url = htmlentities($url); - } return $url; } diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index fce73f6113..2b0019a81c 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -147,7 +147,6 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { $query = NULL, $absolute = FALSE, $fragment = NULL, - $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE ) { @@ -162,7 +161,7 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { $base = $absolute ? $config->userFrameworkBaseURL : $config->useFrameworkRelativeBase; - $separator = $htmlize ? '&' : '&'; + $separator = '&'; if (!$config->cleanURL) { if (isset($path)) { diff --git a/CRM/Utils/System/Joomla.php b/CRM/Utils/System/Joomla.php index 766e4b477f..b063d70adb 100644 --- a/CRM/Utils/System/Joomla.php +++ b/CRM/Utils/System/Joomla.php @@ -251,12 +251,11 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { $query = NULL, $absolute = FALSE, $fragment = NULL, - $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE ) { $config = CRM_Core_Config::singleton(); - $separator = $htmlize ? '&' : '&'; + $separator = '&'; $Itemid = ''; $script = ''; $path = CRM_Utils_String::stripPathChars($path); diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index b3a4bd7a87..142b8f8b43 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -180,13 +180,12 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { $query = NULL, $absolute = FALSE, $fragment = NULL, - $htmlize = TRUE, $frontend = FALSE, $forceBackend = FALSE ) { $config = CRM_Core_Config::singleton(); $script = ''; - $separator = $htmlize ? '&' : '&'; + $separator = '&'; $wpPageParam = ''; $fragment = isset($fragment) ? ('#' . $fragment) : ''; -- 2.25.1