From e407579237a38d0944f9d572faefe95c8cebcf90 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 11 Feb 2020 15:43:54 -0500 Subject: [PATCH] Common.js - remove duplicate function This function did the same thing as the one in lo-dash --- js/Common.js | 19 ------------------- js/jquery/jquery.dashboard.js | 8 ++++---- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/js/Common.js b/js/Common.js index 47c6e48b18..25e228b594 100644 --- a/js/Common.js +++ b/js/Common.js @@ -1598,25 +1598,6 @@ if (!CRM.vars) CRM.vars = {}; return (yiq >= 128) ? 'black' : 'white'; }; - // based on https://github.com/janl/mustache.js/blob/master/mustache.js - // If you feel the need to use this function, consider whether assembling HTML - // via DOM might be a cleaner approach rather than using string concatenation. - CRM.utils.escapeHtml = function(string) { - var entityMap = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''', - '/': '/', - '`': '`', - '=': '=' - }; - return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) { - return entityMap[s]; - }); - } - // CVE-2015-9251 - Prevent auto-execution of scripts when no explicit dataType was provided $.ajaxPrefilter(function(s) { if (s.crossDomain) { diff --git a/js/jquery/jquery.dashboard.js b/js/jquery/jquery.dashboard.js index b87db357d1..b757e27f6c 100644 --- a/js/jquery/jquery.dashboard.js +++ b/js/jquery/jquery.dashboard.js @@ -1,7 +1,7 @@ // https://civicrm.org/licensing /* global CRM, ts */ /*jshint loopfunc: true */ -(function($) { +(function($, _) { 'use strict'; // Constructor for dashboard object. $.fn.dashboard = function(options) { @@ -389,7 +389,7 @@ }); CRM.alert( ts('You can re-add it by clicking the "Configure Your Dashboard" button.'), - ts('"%1" Removed', {1: CRM.utils.escapeHtml(widget.title)}), + ts('"%1" Removed', {1: _.escape(widget.title)}), 'success' ); }; @@ -483,7 +483,7 @@ function widgetHTML() { var html = ''; html += '
'; - html += '

' + CRM.utils.escapeHtml(widget.title) + '

'; + html += '

' + _.escape(widget.title) + '

'; html += '
'; html += '
'; return html; @@ -577,4 +577,4 @@ // id, url, fullscreenUrl, title, name, cacheMinutes } }; -})(jQuery); +})(jQuery, CRM._); -- 2.25.1