Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 使用getDataURL方法获取svg文本时,当有<符号时,没进行转义破坏了xml文档结构 #18192

Closed
minren118 opened this issue Jan 19, 2023 · 1 comment

Comments

@minren118
Copy link

Version

5.3

Link to Minimal Reproduction

No response

Steps to Reproduce

当使用getDataURL对图表进行svg文本输出时,发现ECharts没有对特殊的符号如<进行转义再输出,导致导出的svg文本出错。
浏览器打开会显示这样的标识,实际的内容没法渲染出来。
image

实际内容如下:因<破坏了xml文档结构。
image

当转义后,就正常了。
<5

Current Behavior

未对导出的字符串进行转义。

Expected Behavior

需要对导出的字符串包含特殊字符时,转义后再输出。

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

@minren118 minren118 added the bug label Jan 19, 2023
@echarts-bot echarts-bot bot added the pending We are not sure about whether this is a bug/new feature. label Jan 19, 2023
@echarts-bot
Copy link

echarts-bot bot commented Jan 19, 2023

@minren118 It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗

TRANSLATED

TITLE

[Bug] When using the getDataURL method to get svg text, when there are < symbols, it is not escaped and destroys the xml document structure

BODY

Version

5.3

Link to Minimal Reproduction

No response

Steps to Reproduce

When using getDataURL to output the svg text of the chart, it is found that ECharts does not escape and re-output special symbols such as <, resulting in an error in the exported svg text.
When the browser opens, it will show such a logo, and the actual content cannot be rendered.
image

The actual content is as follows: the XML document structure is broken by <.
image

When escaped, it is normal.
<text dominant-baseline="central" text-anchor="start" style="font: normal normal 14px Microsoft YaHei" x="30" y="7.5" transform="translate(85 520)" fill="#333"><5

Current Behavior

The exported string is not escaped.

Expected Behavior

If you need to include special characters in the exported string, escape it before output.

Environment

- OS:
- Browser:
- Framework:

Any additional comments?

No response

@plainheart plainheart added SVG resolved and removed pending We are not sure about whether this is a bug/new feature. labels Jan 25, 2023
@echarts-bot echarts-bot bot closed this as completed Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants