Skip to content

fix: special characters encoded in layer alerts [DHIS2-19998]#3658

Open
karolinelien wants to merge 1 commit into
masterfrom
fix/special-char-encoding-in-alerts
Open

fix: special characters encoded in layer alerts [DHIS2-19998]#3658
karolinelien wants to merge 1 commit into
masterfrom
fix/special-char-encoding-in-alerts

Conversation

@karolinelien
Copy link
Copy Markdown
Collaborator

@karolinelien karolinelien commented Jun 1, 2026

Summary

Fixes DHIS2-19998: special characters in layer names showed up HTML-encoded (e.g. &lt; instead of <) in the alert bar when a layer is removed.

Root cause

@dhis2/d2-i18n wraps i18next, which HTML-escapes interpolated values by default (<&lt;, &&amp;, etc.). The alert bar renders the message as plain text, so the escaped entities were displayed literally. The codebase already uses i18next's unescaped interpolation syntax {{- name}} for the same reason in FileMenu.jsx.

Changes

  • OverlayCard.jsx — use {{- name}} in the layer-removed alert (the reported bug).
  • DataDownloadDialog.jsx — same fix for the {{layerName}} interpolation in the download dialog, which had the same latent issue.
  • Regenerated i18n/en.pot.
  • Added a regression test (OverlayCard.spec.jsx) that removes a layer named Children < 5y & "others" and asserts the alert receives the raw, unescaped string.

Steps to test

  1. Add a thematic layer using a data element/indicator whose name contains < (e.g. ... < 1 year, common in demo data).
  2. Remove the layer.
  3. The alert bar shows the name with the raw < character (previously &lt;).

Before:
image
image

After:
image

image

Not in scope

ContextMenu.jsx (Show {{name}}, right-click menu for Earth Engine layers) has the same latent escaping but no bundled EE layer name contains special characters, so it does not currently manifest. Can be addressed separately if desired.

AI Assisted

i18next escapes interpolated values by default, so layer names
containing characters like "<", ">", "&" or quotes were rendered as
HTML entities (e.g. "&lt;") in the layer-removed alert and the data
download dialog. Use i18next's unescaped interpolation syntax
({{- name}}) so the raw characters are shown, matching the existing
pattern in FileMenu.

AI Assisted

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 1, 2026

@dhis2-bot
Copy link
Copy Markdown
Contributor

🚀 Deployed on https://pr-3658.maps.netlify.dhis2.org

@dhis2-bot dhis2-bot temporarily deployed to netlify June 1, 2026 13:15 Inactive
@karolinelien karolinelien marked this pull request as ready for review June 1, 2026 14:45
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.

2 participants