[FIX] Only escape HTML from details in toast error messages (#11459)

* Only escape HTML from details in toast error messages

* Refactor reducer
pull/9972/head^2
Tasso Evangelista 8 years ago committed by Guilherme Gazzo
parent 8451e05f64
commit 1cc9aefe48
  1. 7
      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));

Loading…
Cancel
Save