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: svgr-rs does not support unicode chars #1600

Open
stormslowly opened this issue Sep 18, 2024 · 2 comments
Open

bug: svgr-rs does not support unicode chars #1600

stormslowly opened this issue Sep 18, 2024 · 2 comments
Assignees

Comments

@stormslowly
Copy link
Member

stormslowly commented Sep 18, 2024

problem

...
<title>&amp;中文</title>
...
panicked at svgr-rs/src/hast_to_swc_ast/decode_xml.rs:60:21:
byte index 6 is not a char boundary; it is inside '文' (bytes 5..8) of `x&中文`

solution

we don't have to escape by hand, use the crate html-escape

will be fixed in pr #1444

@stormslowly stormslowly self-assigned this Sep 18, 2024
@stormslowly
Copy link
Member Author

the root cause is below
svgr-rs

  1. use swc_xml_parser the svg content , in the html ast. title tag's text children content become &中文 ref
  2. then svgr-rs trying to convert the html ast to swc jsx ast, html entity is concerned, but doing by parsing it by bytes as_bytes()
  3. svgr-rs peeks 2 or 4 bytes after & to convert them to string , then hit byte index 6 is not a char boundary the error

IMO, the best way to solve the problem is , swc_xml_parser un-escaping the text children of html

@stormslowly
Copy link
Member Author

besides this problem, Mako should put compile() in a catch_unwind
in case this problem, node process should get an error other than process abort.

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

No branches or pull requests

1 participant