Remove asterisks from placeholder url
authorColeman Watts <coleman@civicrm.org>
Fri, 7 Jun 2019 00:59:34 +0000 (20:59 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 12 Jun 2019 15:45:16 +0000 (11:45 -0400)
These symbols get escaped by some CMSs which messes up CRM.url

CRM/Utils/System/Drupal8.php
CRM/Utils/System/WordPress.php
js/crm.ajax.js
templates/CRM/common/l10n.js.tpl
tests/karma/unit/crmMailingSpec.js

index ad834da0194c109733d46a3d9922e77d94bb0916..874b63d19162672919f13b6d6c784ec129d8b03b 100644 (file)
@@ -317,14 +317,6 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase {
       \Drupal::logger('civicrm')->error($e->getMessage());
     }
 
-    // Special case: CiviCRM passes us "*path*?*query*" as a skeleton, but asterisks
-    // are invalid and Drupal will attempt to escape them. We unescape them here:
-    if ($path == '*path*') {
-      // First remove trailing equals sign that has been added since the key '?*query*' has no value.
-      $url = rtrim($url, '=');
-      $url = urldecode($url);
-    }
-
     return $url;
   }
 
index 2a13781180151fa8087197c355d2e2dfc8208d0f..b7324eb74ee02a2ba8fb2dd7e886c2672c2dd7f9 100644 (file)
@@ -270,11 +270,7 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
       // pre-existing logic
       if (isset($path)) {
         $queryParts[] = 'page=CiviCRM';
-        // Encode all but the *path* placeholder
-        if ($path !== '*path*') {
-          $path = rawurlencode($path);
-        }
-        $queryParts[] = "q={$path}";
+        $queryParts[] = 'q=' . rawurlencode($path);
       }
       if ($wpPageParam) {
         $queryParts[] = $wpPageParam;
index 23be078e8b5af74a548cd9f2f87501d07fdeacaf..efbcf2c1e35f875d979df2fd686d5a9635b280e2 100644 (file)
     }
     query = query || '';
     var frag = path.split('?');
-    var url = tplURL[mode].replace("*path*", frag[0]);
+    var url = tplURL[mode].replace("civicrm-placeholder-url-path", frag[0]);
 
     if (!query) {
-      url = url.replace(/[?&]\*query\*/, '');
+      url = url.replace(/[?&]civicrm-placeholder-url-query=1/, '');
     }
     else {
-      url = url.replace("*query*", typeof query === 'string' ? query : $.param(query));
+      url = url.replace("civicrm-placeholder-url-query=1", typeof query === 'string' ? query : $.param(query));
     }
     if (frag[1]) {
       url += (url.indexOf('?') < 0 ? '?' : '&') + frag[1];
index f2047652cc8a939367b8e7e55c99b289546d726e..89e923e150de0539436ce11ea77533d1323e7499 100644 (file)
@@ -42,7 +42,7 @@
   CRM.config.entityRef = $.extend({ldelim}{rdelim}, {$entityRef|@json_encode}, CRM.config.entityRef || {ldelim}{rdelim});
 
   // Initialize CRM.url and CRM.formatMoney
-  CRM.url({ldelim}back: '{crmURL p="*path*" q="*query*" h=0 fb=1}', front: '{crmURL p="*path*" q="*query*" h=0 fe=1}'{rdelim});
+  CRM.url({ldelim}back: '{crmURL p="civicrm-placeholder-url-path" q="civicrm-placeholder-url-query=1" h=0 fb=1}', front: '{crmURL p="civicrm-placeholder-url-path" q="civicrm-placeholder-url-query=1" h=0 fe=1}'{rdelim});
   CRM.formatMoney('init', false, {$moneyFormat});
 
   // Localize select2
index 89e966eee2de08b79114952c24ff8158d6971a1a..bd74476213ac791d030228af255226f202ed78cb 100644 (file)
@@ -17,7 +17,7 @@ describe('crmMailing', function() {
         $provide.value('crmNavigator', navigator);
       });
       inject(['crmLegacy', function(crmLegacy) {
-        crmLegacy.url({back: '/*path*?*query*', front: '/*path*?*query*'});
+        crmLegacy.url({back: '/civicrm-placeholder-url-path?civicrm-placeholder-url-query=1', front: '/civicrm-placeholder-url-path?civicrm-placeholder-url-query=1'});
       }]);
       inject(['$controller', function($controller) {
         ctrl = $controller('ListMailingsCtrl', {});