You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2026/06/03 18:56:03 UTC

(superset) branch master updated: fix(nvd3): sanitize generateMultiLineTooltipContent output (#40612)

This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new fcb1e299ace fix(nvd3): sanitize generateMultiLineTooltipContent output (#40612)
fcb1e299ace is described below

commit fcb1e299aceeaae6026b158f79fd282d93a1d8b9
Author: Evan Rusackas <ev...@preset.io>
AuthorDate: Wed Jun 3 11:55:55 2026 -0700

    fix(nvd3): sanitize generateMultiLineTooltipContent output (#40612)
    
    Co-authored-by: Claude Code <no...@anthropic.com>
---
 .../legacy-preset-chart-nvd3/test/utils.test.ts    | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/superset-frontend/plugins/legacy-preset-chart-nvd3/test/utils.test.ts b/superset-frontend/plugins/legacy-preset-chart-nvd3/test/utils.test.ts
index a20fa38411c..f2615771476 100644
--- a/superset-frontend/plugins/legacy-preset-chart-nvd3/test/utils.test.ts
+++ b/superset-frontend/plugins/legacy-preset-chart-nvd3/test/utils.test.ts
@@ -125,6 +125,42 @@ describe('nvd3/utils', () => {
     );
   });
 
+  describe('generateMultiLineTooltipContent()', () => {
+    const identity = (value: any) => value;
+
+    test('renders the series key in the tooltip markup', () => {
+      const tooltip = generateMultiLineTooltipContent(
+        {
+          value: 'x-value',
+          series: [{ key: 'Region A', color: '#fff', value: 1 }],
+        },
+        identity,
+        [identity],
+      );
+      expect(tooltip).toContain('Region A');
+    });
+
+    test('strips a script payload from a malicious series key', () => {
+      const tooltip = generateMultiLineTooltipContent(
+        {
+          value: 'x-value',
+          series: [
+            {
+              key: '<img src=x onerror="alert(1)">',
+              color: '#fff',
+              value: 1,
+            },
+          ],
+        },
+        identity,
+        [identity],
+      );
+      // DOMPurify removes the event handler that would execute on render.
+      expect(tooltip).not.toContain('onerror');
+      expect(tooltip).not.toContain('alert(1)');
+    });
+  });
+
   describe('getTimeOrNumberFormatter(format)', () => {
     test('is a function', () => {
       expect(typeof getTimeOrNumberFormatter).toBe('function');