From 25358c443d26bd7cef39e17d895f944cdf990a0d Mon Sep 17 00:00:00 2001 From: rahuljain-dev Date: Tue, 21 May 2024 19:22:31 +0530 Subject: [PATCH] ELEMENTS-1744: Collection label showing incorrect collection name in right panel --- ui/actions/nuxeo-add-to-collection-button.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/ui/actions/nuxeo-add-to-collection-button.js b/ui/actions/nuxeo-add-to-collection-button.js index 072f1cb17..774c8ecc5 100644 --- a/ui/actions/nuxeo-add-to-collection-button.js +++ b/ui/actions/nuxeo-add-to-collection-button.js @@ -254,8 +254,25 @@ import '../nuxeo-button-styles.js'; return item.id === -1 ? label : escapeHTML(label); } + _escapeHTML(markup) { + const replaceMap = { + '\\': '\', + '&': '&', + '<': '<', + '>': '>', + '/': '/', + }; + + // Do not try to escape the markup if it's not a string + if (typeof markup !== 'string') { + return markup; + } + + return String(markup).replace(/[&<>"/\\]/g, (match) => replaceMap[match]); + } + _newEntryFormatter(term) { - return { id: -1, displayLabel: escapeHTML(term) }; + return { id: -1, displayLabel: this._escapeHTML(term) }; } _isValid() {