Skip to content

Commit ad947d6

Browse files
committed
fix(tooltip): fix tooltip XSS issue when legend name is HTML string
1 parent a282471 commit ad947d6

File tree

2 files changed

+31
-24
lines changed

2 files changed

+31
-24
lines changed

src/util/graphic.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import {
6767
} from 'zrender/src/core/util';
6868
import { getECData } from './innerStore';
6969
import ComponentModel from '../model/Component';
70+
import { encodeHTML } from 'zrender/src/core/dom';
7071

7172

7273
import {
@@ -600,10 +601,11 @@ export function setTooltipConfig(opt: {
600601
const ecData = getECData(opt.el);
601602
ecData.componentMainType = mainType;
602603
ecData.componentIndex = componentIndex;
604+
603605
ecData.tooltipConfig = {
604606
name: itemName,
605607
option: defaults({
606-
content: itemName,
608+
content: encodeHTML(itemName),
607609
formatterParams: formatterParams
608610
}, itemTooltipOptionObj)
609611
};

test/tooltip.html

Lines changed: 28 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)