Skip to content

fix(dashboard): show chart tooltip labels as text, and decode keys like the api does (24.05) - #7883

Open
ar2rsawseen wants to merge 1 commit into
release.24.05from
backport/chart-tooltip-label-rendering-2405
Open

fix(dashboard): show chart tooltip labels as text, and decode keys like the api does (24.05)#7883
ar2rsawseen wants to merge 1 commit into
release.24.05from
backport/chart-tooltip-label-rendering-2405

Conversation

@ar2rsawseen

Copy link
Copy Markdown
Member

Backport of #7882, which has the full write-up. All three functions are identical on this branch, so the patch applied unchanged.

sanitizeHtml encoded its input and then immediately unescaped it. Those two are inverses, so it returned the input unchanged and a label containing markup went into a tooltip template as markup rather than being shown as text. It now normalises first and escapes last: undo the html escaping the api applies, undo the key substitutions, then escape once.

Separately, the dashboard's key decoder undid only $ and . while the api encoder also substitutes NUL and the api decoder accepts the url encoded forms, so &#9647, $ and . reached callers still encoded. Both directions of the dashboard pair now match the api.

One visible consequence: a value containing NUL shows the character itself, which is invisible, where it previously showed the placeholder glyph the browser resolved &#9647 into. NUL in a key or segment value is pathological, and the alternative was leaving one of the two decoders knowingly incomplete.

Verification

  • 43 tests, all passing here unchanged: 13 on the tooltip helper (4 fail without the change) and 30 asserting the two substitution pairs agree behaviourally (6 fail without it).
  • Full unit suite: 101 passing before, 144 after, same 5 pre-existing failures (validateArgs extra types, Countly Request). Baseline captured by reverting and re-running.
  • eslint clean. No raw NUL bytes in the source; the escape is written as \u0000.

🤖 Generated with Claude Code

…ke the api does (24.05)

Backport of the master change. All three functions are identical on this branch,
so the patch applied unchanged.

sanitizeHtml encoded its input and then immediately unescaped it. Those two are
inverses, so it returned the input unchanged and a label containing markup went
into a tooltip template as markup rather than being shown as text. It now
normalises first and escapes last: undo the html escaping the api applies, undo
the key substitutions, then escape once.

The dashboard's key decoder also undid only $ and . while the api encoder
substitutes NUL as well and the api decoder accepts the url encoded forms, so
&#9647, $ and . reached callers still encoded. Both directions of
the dashboard pair now match the api.

One visible consequence: a value containing NUL shows the character itself, which
is invisible, where it previously showed the placeholder glyph the browser
resolved &#9647 into.

Full unit suite on this branch: 101 passing before, 144 after, same 5 pre-existing
failures (validateArgs extra types, Countly Request). eslint clean.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.

1 participant