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

Canvas#toDataURL() returns image data url string with quotes included #124

Open
rocwind opened this issue Apr 4, 2019 · 9 comments
Open

Comments

@rocwind
Copy link
Contributor

rocwind commented Apr 4, 2019

Canvas#toDataURL() returns a string like "\"data:image/png;base64,iVB...\"".

It seems caused by the payload being JSON.stringify() at web view side: https://github.com/iddan/react-native-canvas/blob/master/src/webview.js#L88
and get returned directly at React Native side:
https://github.com/iddan/react-native-canvas/blob/master/src/Canvas.js#L76

@fabiancook
Copy link

Please can we document this as it isn't the same signature as what is on the web.

Because of me just ignoring the quotes when I read them in the console, I didn't notice the extra quotes D: Took me a while to figure out that one.

@iddan
Copy link
Owner

iddan commented Jul 7, 2019

I'll accept a PR for a solution

@kimmy-wang
Copy link

Calling this method gives an error. The operation is insecure.
repo

@chj-damon
Copy link

Please can we document this as it isn't the same signature as what is on the web.

Because of me just ignoring the quotes when I read them in the console, I didn't notice the extra quotes D: Took me a while to figure out that one.

I feel desperate after figured out that's the reason why I can't save image

@xwg2015
Copy link

xwg2015 commented Sep 9, 2021

Calling this method gives an error. The operation is insecure.
repo

the same problem

@doublelam
Copy link

hi, anything new for this issue?

@mikepj
Copy link

mikepj commented Nov 24, 2021

I just ran into this issue after spending a few hours debugging. I worked around it by replacing the quotes in the string returned:

imageData = await canvas.toDataURL();
imageData = imageData.replace(/^"|"$/g, ``);

I'm not sure what the best solution is here. Singling out the toDataURL call when choosing whether to stringify the response message in the code @rocwind linked above doesn't feel right.

@telpat0298
Copy link

Has anybody found a solution to the This operation is insecure problem?

@witherBattler
Copy link

witherBattler commented Feb 25, 2023

This is so stupid. Already 4 years and this still isn't fixed.

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

10 participants