fix: special characters encoded in layer alerts [DHIS2-19998]#3658
Open
karolinelien wants to merge 1 commit into
Open
fix: special characters encoded in layer alerts [DHIS2-19998]#3658karolinelien wants to merge 1 commit into
karolinelien wants to merge 1 commit into
Conversation
i18next escapes interpolated values by default, so layer names
containing characters like "<", ">", "&" or quotes were rendered as
HTML entities (e.g. "<") 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>
|
Contributor
|
🚀 Deployed on https://pr-3658.maps.netlify.dhis2.org |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Fixes DHIS2-19998: special characters in layer names showed up HTML-encoded (e.g.
<instead of<) in the alert bar when a layer is removed.Root cause
@dhis2/d2-i18nwraps i18next, which HTML-escapes interpolated values by default (<→<,&→&, 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 inFileMenu.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.i18n/en.pot.OverlayCard.spec.jsx) that removes a layer namedChildren < 5y & "others"and asserts the alert receives the raw, unescaped string.Steps to test
<(e.g.... < 1 year, common in demo data).<character (previously<).Before:


After:

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