From 1cc9aefe48ddcb520ea9c1e2117b66cce4e11d7a Mon Sep 17 00:00:00 2001 From: Tasso Evangelista Date: Tue, 17 Jul 2018 20:21:33 -0300 Subject: [PATCH] [FIX] Only escape HTML from details in toast error messages (#11459) * Only escape HTML from details in toast error messages * Refactor reducer --- client/lib/handleError.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/lib/handleError.js b/client/lib/handleError.js index 9fdd054cd43..84aa1cf60fd 100644 --- a/client/lib/handleError.js +++ b/client/lib/handleError.js @@ -12,7 +12,12 @@ this.handleError = function(error, useToastr = true) { } if (useToastr) { - return toastr.error(s.escapeHTML(TAPi18n.__(error.error, error.details)), error.details && error.details.errorTitle ? s.escapeHTML(TAPi18n.__(error.details.errorTitle)) : null); + const details = Object.entries(error.details || {}) + .reduce((obj, [ key, value ]) => ({ ...obj, [key] : s.escapeHTML(value) }), {}); + const message = TAPi18n.__(error.error, details); + const title = details.errorTitle && TAPi18n.__(details.errorTitle); + + return toastr.error(message, title); } return s.escapeHTML(TAPi18n.__(error.error, error.details));