From 30f131c52f838de764f338c047db0541580e5025 Mon Sep 17 00:00:00 2001 From: Stefano Ricci <1219739+SteRiccio@users.noreply.github.com> Date: Fri, 20 Dec 2024 13:20:53 +0100 Subject: [PATCH] Job dialog / errors export: fixed character encoding issue (#3698) Co-authored-by: Stefano Ricci Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- webapp/utils/domUtils.js | 10 ++++++++++ webapp/views/App/JobMonitor/JobErrors/JobErrors.js | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/webapp/utils/domUtils.js b/webapp/utils/domUtils.js index 2ded899d47..5260562b83 100644 --- a/webapp/utils/domUtils.js +++ b/webapp/utils/domUtils.js @@ -86,3 +86,13 @@ export const downloadSvgToPng = (svgElement) => { URL.revokeObjectURL(url) } } + +export const htmlToString = (html) => { + try { + const div = document.createElement('div') + div.setHTMLUnsafe(html) + return div.innerText + } catch (error) { + return html + } +} diff --git a/webapp/views/App/JobMonitor/JobErrors/JobErrors.js b/webapp/views/App/JobMonitor/JobErrors/JobErrors.js index 5a11fc222e..93b4eabb63 100644 --- a/webapp/views/App/JobMonitor/JobErrors/JobErrors.js +++ b/webapp/views/App/JobMonitor/JobErrors/JobErrors.js @@ -4,6 +4,8 @@ import PropTypes from 'prop-types' import * as JobSerialized from '@common/job/jobSerialized' import { ValidationUtils } from '@core/validation/validationUtils' +import { htmlToString } from '@webapp/utils/domUtils' + import { useSurvey } from '@webapp/store/survey' import { useI18n } from '@webapp/store/system' @@ -53,7 +55,7 @@ const JobErrors = ({ valueFormatter: (value) => { const validation = toValidation(value) const jointMessages = ValidationUtils.getJointMessages({ i18n, survey, showKeys: false })(validation) - return jointMessages.map(({ text }) => text).join(', ') + return jointMessages.map(({ text }) => htmlToString(text)).join(', ') }, }, ]}