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

feat: add un-escape special symbols functionality #2426

Closed
wants to merge 3 commits into from

Conversation

bohdanprog
Copy link
Member

Summary

Fixes #2411
Motivation: the parse function does not un-escape text from the SVG element. It prevents displaying special characters (such as <, >, &, and others) in SVG text elements.

Test Plan

The example is available in the test-examples app as Test2411

Compatibility

OS Implemented
iOS
MacOS
Android
Web

@bohdanprog bohdanprog self-assigned this Aug 23, 2024
@bohdanprog bohdanprog requested a review from jakex7 August 23, 2024 07:04
@jakex7
Copy link
Member

jakex7 commented Aug 23, 2024

It prevents displaying special characters (such as <, >, &, and others) in SVG text elements.

It seems to me that it is doing the opposite. With this function we will be able to display this three escaped characters: < > &.

Copy link
Member

@jakex7 jakex7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left my comment. Maybe it fixes this specific issue, but we should consider the broader context.

Comment on lines +277 to +279
.replace(/&amp;/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>');
Copy link
Member

@jakex7 jakex7 Aug 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making an exception for some character just seems wrong. What about &apos; or &quot;? There are dozens of characters that could be unescaped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, you're right.

Comment on lines +277 to +279
.replace(/&amp;/g, '&')
.replace(/&lt;/g, '<')
.replace(/&gt;/g, '>');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, what about numeric character references? According to the spec, it's also a valid text content. Example:&lt; can be represented as &#60;, &gt; as &#62; and &amp; as &#38;

@bohdanprog
Copy link
Member Author

I guess we have to find another solution for that, that's why I closed that PR.

@bohdanprog bohdanprog closed this Aug 23, 2024
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.

SvgUri/SvgFromXml components don't un-escape special symbols
2 participants