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

dataURI matching regex needs to match on start of string #203

Closed
wigsaparelli opened this issue Jun 29, 2023 · 0 comments
Closed

dataURI matching regex needs to match on start of string #203

wigsaparelli opened this issue Jun 29, 2023 · 0 comments

Comments

@wigsaparelli
Copy link

wigsaparelli commented Jun 29, 2023

Describe the bug
The component blows up when calling window.atob(dataURI[2]) if its src property contains an inline svg (a string beginning with '<svg' character sequence) and the svg contains dataURI links to embedded images. I have attached an example svg.

To Reproduce
Try with the attached svg that contains links to embedded images (as data URIs) - perfectly valid. It will blow up when executing window.atob(dataURI[2])

Expected behavior
Embeded image links within a svg should be fine.

Link to repl or repo (highly encouraged)
Just test with attached svg

Additional context
The issue is the regex for detecting a dataURI. It should be matching on the start of string character (and ideally, although not essential in this case, should include the Unicode flag on the end).
i.e. change the line:
const dataURI = src.match(/data:image\/svg[^,]*?(;base64)?,(.*)/);
to the line:
const dataURI = src.match(/^data:image\/svg[^,]*?(;base64)?,(.*)/u);

withImages

gilbarbara added a commit that referenced this issue Aug 6, 2023
gilbarbara added a commit that referenced this issue Aug 6, 2023
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