-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
base64 string got from ImageEditor.cropImage(uri) have linefeed after each 76 characters. #11142
Comments
Good find, thanks for reporting it! Note that RN releases older than latest are not supported, can you try if the bug is still present in the latest release? Would you be up for fixing it here? Found this: http://stackoverflow.com/questions/19952621/is-it-ok-to-remove-newline-in-base64-encoding |
Yeah I don't mind taking a look. |
Closing this issue because it has been inactive for a while. If you think it should still be opened let us know why. |
Summary: FIX #11142 This fixes #11142 and supersedes #11155 as I was unsure how to add/change commits in that PR. Wrote up a bunch of unit tests for the ImageStore module. The added tests showed that there was indeed a problem with the flags used for the Base64OutputStream, and they also show that that has been fixed now. Closes #13856 Differential Revision: D6017764 Pulled By: shergin fbshipit-source-id: adf667dc722ddfe31449afd8cd20a0a192eacff6
Description
I launched "react-native run-android" on MAC 10.11.6 (15G1004). I found when I use ImageEditor.cropImage(uri) to crop an image, the base64 text of image is not as my expected. Base64 text of image should be a whole string. But I found there is a linefeed after each 76 characters. When I put it as a JOSN object value, and stringify the JSON object. Then I try to parse this JSON object. I will meet a error: Unexpected Token. If I use base64Text.replace("\n", "").replace("\r",""), then It's ok;
for example:
ImageStore.getBase64ForTag(url, (base64Data) => {
let sImageBase64Data = "data:image/jpg;base64," + base64Data.replace(/\n|\r/g, "");
}
Solution
Replace all linefeed and carriage-return by base64Data.replace(/\n|\r/g, "").
Additional Information
The text was updated successfully, but these errors were encountered: