Skip to content

CHI-3741: Render HTML in checkbox labels in Aselo Webchat#4119

Open
stephenhand wants to merge 6 commits intomasterfrom
CHI-3741-html_in_webchat_labels
Open

CHI-3741: Render HTML in checkbox labels in Aselo Webchat#4119
stephenhand wants to merge 6 commits intomasterfrom
CHI-3741-html_in_webchat_labels

Conversation

@stephenhand
Copy link
Copy Markdown
Collaborator

@stephenhand stephenhand commented Mar 31, 2026

Description

  • Add a renderAsHtml option to LocalizedTemplate component to allow inline HTML rendering
  • Sanitize HTML output using DOMPurify with a strict allowlist (only links and text decoration tags: <a>, <b>, <i>, <em>, <strong>, <u>, <s>, <span>, <br>; only href and rel attributes permitted) to prevent XSS
  • Set renderAsHtml for checkbox labels only (we want to try to use it as little as possible)

Checklist

  • Corresponding issue has been opened
  • New tests added
  • Feature flags added
  • [n/a] Strings are localized
  • Tested for chat contacts
  • [n/s] Tested for call contacts

Other Related Issues

None

Verification steps

AFTER YOU MERGE

  1. Cut a release tag using the Github workflow. Wait for it to complete and notify in the #aselo-deploys Slack channel.
  2. Comment on the ticket with the release tag version AND any additional instructions required to configure an environment to test the changes.
  3. Only then move the ticket into the QA column in JIRA

You are responsible for ensuring the above steps are completed. If you move a ticket into QA without advising what version to test, the QA team will assume the latest tag has the changes. If it does not, the following confusion is on you! :-P

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Aselo Webchat localization rendering to optionally allow inline HTML, and enables that option specifically for pre-engagement form checkbox labels.

Changes:

  • Add a renderAsHtml option to LocalizedTemplate that renders translation output via dangerouslySetInnerHTML.
  • Enable HTML rendering for checkbox labels in the pre-engagement form.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
aselo-webchat-react-app/src/localization/LocalizedTemplate.tsx Adds an opt-in HTML rendering path for localized template output.
aselo-webchat-react-app/src/components/forms/formInputs/Checkbox.tsx Uses the new HTML rendering option for checkbox labels.

Comment on lines +28 to +31
if (renderAsHtml?.toLowerCase() === 'true') {
// eslint-disable-next-line react/no-danger
return <span dangerouslySetInnerHTML={{ __html: translateForCurrentLocale(code, parameters) }} />;
}
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renderAsHtml switches to dangerouslySetInnerHTML with the raw output of translateForCurrentLocale(...). Since translations are loaded from runtime config, this can become an XSS vector if any translation content is ever user/admin-controlled. Please sanitize/allowlist the HTML before injecting it (or parse to React elements with a strict allowlist) and explicitly prevent unsafe tags/attrs like script, on* handlers, and javascript: URLs.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

@stephenhand stephenhand Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

The ideally the allow list should only permit links and text decoration / style changes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added DOMPurify sanitization in commit e2a099b. The allowlist only permits links (<a> with href and rel attributes) and text decoration/style tags (<b>, <i>, <em>, <strong>, <u>, <s>, <span>, <br>). All other tags, event handlers (on*), javascript: URLs, and unsafe attributes are blocked by DOMPurify.

stephenhand and others added 4 commits April 1, 2026 07:59
…ox.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.cypress.io
    • Triggering command: /opt/hostedtoolcache/node/20.20.1/x64/bin/node node dist/index.js --exec install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

… into CHI-3741-html_in_webchat_labels

# Conflicts:
#	aselo-webchat-react-app/src/localization/LocalizedTemplate.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants