Skip to content

Commit

Permalink
Job dialog / errors export: fixed character encoding issue (#3698)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefano Ricci <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 20, 2024
1 parent b903d8e commit 30f131c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions webapp/utils/domUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
4 changes: 3 additions & 1 deletion webapp/views/App/JobMonitor/JobErrors/JobErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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(', ')
},
},
]}
Expand Down

0 comments on commit 30f131c

Please sign in to comment.