Use JS escaping for {ts} calls in a JS context
authorBradley Taylor <hello@brad-taylor.co.uk>
Fri, 31 Dec 2021 11:13:12 +0000 (11:13 +0000)
committerBradley Taylor <hello@brad-taylor.co.uk>
Fri, 31 Dec 2021 11:13:12 +0000 (11:13 +0000)
templates/CRM/Campaign/Form/Task/Interview.tpl
templates/CRM/Contact/Form/Edit/Lock.tpl
templates/CRM/Contact/Form/Merge.tpl
templates/CRM/Contact/Form/ShareAddress.tpl
templates/CRM/Contribute/Form/Contribution.tpl
templates/CRM/Event/Form/SelfSvcUpdate.tpl

index 2987636b71467589ec7c8c2c009494a67db313d6..5c5d29a94f1ee9b7f17ef5beaee26b0de78af1df 100644 (file)
@@ -311,7 +311,7 @@ var surveyActivityIds = {/literal}{$surveyActivityIds}{literal};
         if (interview.errors[error]) errorList =  errorList + '<li>' + interview.errors[error] + '</li>';
       }
       if ( errorList ) {
-        var allErrors = '<i class="crm-i fa-exclamation-triangle crm-i-red" aria-hidden="true"></i> {/literal}{ts}Please correct the following errors in the survey fields below:{/ts}{literal}<ul>' + errorList + '</ul>';
+        var allErrors = '<i class="crm-i fa-exclamation-triangle crm-i-red" aria-hidden="true"></i> {/literal}{ts escape='js'}Please correct the following errors in the survey fields below:{/ts}{literal}<ul>' + errorList + '</ul>';
         CRM.$('#responseErrors').show( ).html(allErrors);
       }
     }
index bca56db29bc36cd1888f4130106367d60af9844c..da62b6d41b84a3ca9f8991ce2f9894444e17fd0d 100644 (file)
@@ -7,7 +7,7 @@ CRM.$(function($) {
   $('<br>')
     .appendTo($('#update_modified_date'));
   $('<button>')
-    .text("{/literal}{ts}Save Anyway{/ts}{literal}")
+    .text("{/literal}{ts escape='js'}Save Anyway{/ts}{literal}")
     .click(function() {
       $('input[name="modified_date"]').val(
               $('#update_modified_date').attr('data:latest_modified_date')
@@ -18,7 +18,7 @@ CRM.$(function($) {
     .appendTo($('#update_modified_date'))
     ;
   $('<button>')
-    .text("{/literal}{ts}Reload Page{/ts}{literal}")
+    .text("{/literal}{ts escape='js'}Reload Page{/ts}{literal}")
     .click(function() {
       window.location.href = CRM.url('civicrm/contact/add', {
         reset: 1,
index 704bd7fffaa4a83bb7cfe3e31605701792f403c5..e7cf5c32ade272680819418de4a084c5def25757 100644 (file)
     var add_new_check_length = this_controls.find(".location_operation_checkbox input:checked").length;
     if (mainBlock != false) {
       if (add_new_check_length > 0) {
-        operation_description = "{/literal}{ts}add new{/ts}{literal}";
+        operation_description = "{/literal}{ts escape='js'}add new{/ts}{literal}";
       }
       else {
-        operation_description = "{/literal}{ts}overwrite{/ts}{literal}";
+        operation_description = "{/literal}{ts escape='js'}overwrite{/ts}{literal}";
       }
     }
     this_controls.find(".location_operation_description").text("(" + operation_description + ")");
       if (mainBlock != false && (blockName == 'email' || blockName == 'phone')) {
         var op_id = 'location_blocks[' + blockName + '][' + blockId + '][operation]';
         this_controls.find(".location_operation_checkbox").html(
-                '<input id="' + op_id + '" name="' + op_id + '" type="checkbox" value="1" class="crm-form-checkbox"><label for="' + op_id + '">{/literal}{ts}Add new{/ts}{literal}</label>'
+                '<input id="' + op_id + '" name="' + op_id + '" type="checkbox" value="1" class="crm-form-checkbox"><label for="' + op_id + '">{/literal}{ts escape='js'}Add new{/ts}{literal}</label>'
         );
       }
       else {
       if (blockName != 'website' && (mainBlock == false || mainBlock['is_primary'] != "1" || add_new_check_length > 0)) {
         var prim_id = 'location_blocks[' + blockName + '][' + blockId + '][set_other_primary]';
         this_controls.find(".location_set_other_primary").html(
-                '<input id="' + prim_id + '" name="' + prim_id + '" type="checkbox" value="1" class="crm-form-checkbox"><label for="' + prim_id + '">{/literal}{ts}Set as primary{/ts}{literal}</label>'
+                '<input id="' + prim_id + '" name="' + prim_id + '" type="checkbox" value="1" class="crm-form-checkbox"><label for="' + prim_id + '">{/literal}{ts escape='js'}Set as primary{/ts}{literal}</label>'
         );
       }
       else {
index e8d780d8df7327941f433f80f0ae9d0a9ab633b2..d434ba6060ad00071f6c9c8202641e3803ae8109 100644 (file)
             });
 
             if (!addressHTML) {
-              addressHTML = {/literal}"{ts escape='js'}Selected contact does not have an address. Please click the following link to edit that contact to add an address, or select a different contact.{/ts}"{literal} + ' <a target="_blank" href="' + CRM.url('civicrm/contact/add', 'reset=1&action=update&cid=' + sharedContactId) + '">{/literal}{ts}Edit Contact Details{/ts}{literal}</a>';
+              addressHTML = {/literal}"{ts escape='js'}Selected contact does not have an address. Please click the following link to edit that contact to add an address, or select a different contact.{/ts}"{literal} + ' <a target="_blank" href="' + CRM.url('civicrm/contact/add', 'reset=1&action=update&cid=' + sharedContactId) + '">{/literal}{ts escape='js'}Edit Contact Details{/ts}{literal}</a>';
             }
 
             $contentArea.html(addressHTML);
index ccf25e943be6d0b01179ca89204a561d6c2e69eb..a0e62b165df5d71457dafe509ab77a060983889e 100644 (file)
       var choose = "{/literal}{ts escape='js'}Choose price set{/ts}{literal}";
       cj("#price_set_id option[value='']").html(choose);
 
-      cj('label[for="total_amount"]').text('{/literal}{ts}Total Amount{/ts}{literal}');
+      cj('label[for="total_amount"]').text('{/literal}{ts escape='js'}Total Amount{/ts}{literal}');
       cj(".crm-contribution-form-block-financial_type_id").show();
       cj("#financial_type_id option[value='']").attr('selected', true);
 
     var manual = "{/literal}{ts escape='js'}Manual contribution amount{/ts}{literal}";
     cj("#price_set_id option[value='']").html(manual);
 
-    cj('label[for="total_amount"]').text('{/literal}{ts}Price Sets{/ts}{literal}');
+    cj('label[for="total_amount"]').text('{/literal}{ts escape='js'}Price Sets{/ts}{literal}');
     if (financialtypeIds) {
       cj("#financial_type_id option[value="+financialtypeIds[priceSetId]+"]").prop('selected', true);
     }
index 117afc4df438df6e90de2e099eb818ae3703bd40..b3f68c223db33766e58b8e16c65814ce57dda7f2 100644 (file)
@@ -40,7 +40,7 @@
     $('#action').on('change', function() {
       selected = $(this).find("option:selected").text();
       if (selected == 'Cancel' && contributionID) {
-        CRM.alert('{/literal}{ts}Cancellations are not refundable.{/ts}{literal}', 'Warning', 'alert');
+        CRM.alert('{/literal}{ts escape='js'}Cancellations are not refundable.{/ts}{literal}', 'Warning', 'alert');
       }
     });
   });