From 8ac8527b5e6eedd7697ab9a4a7e9d3227eb028d6 Mon Sep 17 00:00:00 2001 From: colemanw Date: Thu, 20 Jul 2023 12:36:55 -0400 Subject: [PATCH] CRM_Utils_System::url - Remove unused param to double-escape html --- CRM/Utils/System.php | 8 ++++---- CRM/Utils/System/Base.php | 18 +++++------------- CRM/Utils/System/Drupal8.php | 3 +-- CRM/Utils/System/DrupalBase.php | 3 +-- CRM/Utils/System/Joomla.php | 3 +-- CRM/Utils/System/Standalone.php | 3 +-- CRM/Utils/System/UnitTests.php | 7 ++----- CRM/Utils/System/WordPress.php | 6 ++---- .../phpunit/CRM/Mailing/MailingSystemTest.php | 2 +- tests/phpunit/api/v3/MailingTest.php | 2 +- 10 files changed, 19 insertions(+), 36 deletions(-) diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 774a4b3740..641cf3ae15 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -278,7 +278,7 @@ class CRM_Utils_System { } $config = CRM_Core_Config::singleton(); - $url = $config->userSystem->url($path, $query, $absolute, $fragment, $frontend, $forceBackend, $htmlize); + $url = $config->userSystem->url($path, $query, $absolute, $fragment, $frontend, $forceBackend); if ($htmlize) { $url = htmlentities($url); @@ -301,7 +301,7 @@ class CRM_Utils_System { * @param string $fragment * A fragment identifier (named anchor) to append to the link. * @param bool $htmlize - * Whether to encode special html characters such as &. + * Unused param * @param bool $frontend * This link should be to the CMS front end (applies to WP & Joomla). * @param bool $forceBackend @@ -315,13 +315,13 @@ class CRM_Utils_System { $query = NULL, $absolute = FALSE, $fragment = NULL, - $htmlize = TRUE, + $htmlize = NULL, $frontend = FALSE, $forceBackend = FALSE ) { $config = CRM_Core_Config::singleton(); $query = self::makeQueryString($query); - return $config->userSystem->getNotifyUrl($path, $query, $absolute, $fragment, $frontend, $forceBackend, $htmlize); + return $config->userSystem->getNotifyUrl($path, $query, $absolute, $fragment, $frontend, $forceBackend); } /** diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 0c050d622c..c78f72c0c9 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -124,22 +124,17 @@ abstract class CRM_Utils_System_Base { * This link should be to the CMS front end (applies to WP & Joomla). * @param bool $forceBackend * This link should be to the CMS back end (applies to WP & Joomla). - * @param bool $htmlize - * Whether to encode special html characters such as &. * * @return string */ - public function url( + abstract public function url( $path = NULL, $query = NULL, $absolute = FALSE, $fragment = NULL, $frontend = FALSE, - $forceBackend = FALSE, - $htmlize = TRUE - ) { - return NULL; - } + $forceBackend = FALSE + ); /** * Return the Notification URL for Payments. @@ -162,8 +157,6 @@ abstract class CRM_Utils_System_Base { * This link should be to the CMS front end (applies to WP & Joomla). * @param bool $forceBackend * This link should be to the CMS back end (applies to WP & Joomla). - * @param bool $htmlize - * Whether to encode special html characters such as &. * * @return string * The Notification URL. @@ -174,10 +167,9 @@ abstract class CRM_Utils_System_Base { $absolute = FALSE, $fragment = NULL, $frontend = FALSE, - $forceBackend = FALSE, - $htmlize = TRUE + $forceBackend = FALSE ) { - return $this->url($path, $query, $absolute, $fragment, $frontend, $forceBackend, $htmlize); + return $this->url($path, $query, $absolute, $fragment, $frontend, $forceBackend); } /** diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index 8fcddf4de2..af6821e182 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -280,8 +280,7 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { $absolute = FALSE, $fragment = NULL, $frontend = FALSE, - $forceBackend = FALSE, - $htmlize = TRUE + $forceBackend = FALSE ) { $query = html_entity_decode($query); diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index 3574213f7d..c68a5c01f5 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -154,8 +154,7 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { $absolute = FALSE, $fragment = NULL, $frontend = FALSE, - $forceBackend = FALSE, - $htmlize = TRUE + $forceBackend = FALSE ) { $config = CRM_Core_Config::singleton(); $script = 'index.php'; diff --git a/CRM/Utils/System/Joomla.php b/CRM/Utils/System/Joomla.php index 8cc3592de2..1f215d2a4b 100644 --- a/CRM/Utils/System/Joomla.php +++ b/CRM/Utils/System/Joomla.php @@ -261,8 +261,7 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { $absolute = FALSE, $fragment = NULL, $frontend = FALSE, - $forceBackend = FALSE, - $htmlize = TRUE + $forceBackend = FALSE ) { $config = CRM_Core_Config::singleton(); $separator = '&'; diff --git a/CRM/Utils/System/Standalone.php b/CRM/Utils/System/Standalone.php index e0203e0be0..3b33669a01 100644 --- a/CRM/Utils/System/Standalone.php +++ b/CRM/Utils/System/Standalone.php @@ -187,8 +187,7 @@ class CRM_Utils_System_Standalone extends CRM_Utils_System_Base { $absolute = FALSE, $fragment = NULL, $frontend = FALSE, - $forceBackend = FALSE, - $htmlize = TRUE + $forceBackend = FALSE ) { $fragment = $fragment ? ('#' . $fragment) : ''; if ($absolute) { diff --git a/CRM/Utils/System/UnitTests.php b/CRM/Utils/System/UnitTests.php index 089d4e0325..8aea53af58 100644 --- a/CRM/Utils/System/UnitTests.php +++ b/CRM/Utils/System/UnitTests.php @@ -100,8 +100,7 @@ class CRM_Utils_System_UnitTests extends CRM_Utils_System_Base { $absolute = FALSE, $fragment = NULL, $frontend = FALSE, - $forceBackend = FALSE, - $htmlize = TRUE + $forceBackend = FALSE ) { $config = CRM_Core_Config::singleton(); static $script = 'index.php'; @@ -116,12 +115,10 @@ class CRM_Utils_System_UnitTests extends CRM_Utils_System_Base { } $base = $absolute ? $config->userFrameworkBaseURL : $config->useFrameworkRelativeBase; - $separator = ($htmlize && $frontend) ? '&' : '&'; - if (!$config->cleanURL) { if ($path !== NULL && $path !== '' && $path !== FALSE) { if ($query !== NULL && $query !== '' && $query !== FALSE) { - return $base . $script . '?q=' . $path . $separator . $query . $fragment; + return $base . $script . '?q=' . $path . '&' . $query . $fragment; } else { return $base . $script . '?q=' . $path . $fragment; diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index 4b623ce37a..0ea69aaa9a 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -297,8 +297,7 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { $absolute = FALSE, $fragment = NULL, $frontend = FALSE, - $forceBackend = FALSE, - $htmlize = TRUE + $forceBackend = FALSE ) { $config = CRM_Core_Config::singleton(); $script = ''; @@ -474,8 +473,7 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { $absolute = FALSE, $fragment = NULL, $frontend = FALSE, - $forceBackend = FALSE, - $htmlize = TRUE + $forceBackend = FALSE ) { $config = CRM_Core_Config::singleton(); $separator = '&'; diff --git a/tests/phpunit/CRM/Mailing/MailingSystemTest.php b/tests/phpunit/CRM/Mailing/MailingSystemTest.php index 264ff4f674..d48267ccb5 100644 --- a/tests/phpunit/CRM/Mailing/MailingSystemTest.php +++ b/tests/phpunit/CRM/Mailing/MailingSystemTest.php @@ -93,7 +93,7 @@ class CRM_Mailing_MailingSystemTest extends CRM_Mailing_BaseMailingSystemTest { $result = $this->callAPISuccess('mailing', 'create', $params); $previewResult = $result['values'][$result['id']]['api.Mailing.preview']; $this->assertRegexp('!>Forward this email written in ckeditor!', $previewResult['values']['body_html']); - $this->assertRegexp('!!', $previewResult['values']['body_html']); + $this->assertRegexp('!!', $previewResult['values']['body_html']); $this->assertStringNotContainsString("http://http://", $previewResult['values']['body_html']); } diff --git a/tests/phpunit/api/v3/MailingTest.php b/tests/phpunit/api/v3/MailingTest.php index de9c765597..51a3308c46 100644 --- a/tests/phpunit/api/v3/MailingTest.php +++ b/tests/phpunit/api/v3/MailingTest.php @@ -303,7 +303,7 @@ class api_v3_MailingTest extends CiviUnitTestCase { $this->assertStringContainsString("This is $displayName", $previewResult['values']['body_text']); $this->assertStringContainsString("

This is $displayName.

", $previewResult['values']['body_html']); $this->assertRegexp('!>Forward this email
!', $previewResult['values']['body_html']); - $this->assertRegexp('!!', $previewResult['values']['body_html']); + $this->assertRegexp('!!', $previewResult['values']['body_html']); $this->assertStringNotContainsString("http://http://", $previewResult['values']['body_html']); } -- 2.25.1