[
https://issues.apache.org/jira/browse/CB-6388?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13957635#comment-13957635
]
Ian Clelland commented on CB-6388:
----------------------------------
I think the right thing to do here is to change the serialization format,
including a function to call to correctly interpret the data, depending on its
intended format ({{MESSAGE_TYPE_BINARY_STRING}} or
{{MESSAGE_TYPE_ARRAYBUFFER}}).
Either of these formats would work (presuming cordova.utils.atoab is defined
correctly):
{code:title=Decode to Binary String}
cordova.callbackFromNative('File1615636988',true,1,[atob("4oKsw6sgLSBUaGVyZSBpcyBhbiBleGNlcHRpb24gdG8gZXZlcnkgcnVsZS4gIEV4Y2VwdCB0aGlzIG9uZS5iaW46AQA=")],false);
{code}
{code:title=Decode to ArrayBuffer}
cordova.callbackFromNative('File1615636988',true,1,[cordova.utils.atoab("4oKsw6sgLSBUaGVyZSBpcyBhbiBleGNlcHRpb24gdG8gZXZlcnkgcnVsZS4gIEV4Y2VwdCB0aGlzIG9uZS5iaW46AQA=")],false);
{code}
> LOAD_URL Bridge fails to return binary data
> -------------------------------------------
>
> Key: CB-6388
> URL: https://issues.apache.org/jira/browse/CB-6388
> Project: Apache Cordova
> Issue Type: Bug
> Components: Android
> Affects Versions: 3.4.0
> Reporter: Ian Clelland
>
> In LOAD_URL nativeToJs mode, the Android native side of the bridge
> incorrectly encodes binary data.
> It serializes the data to Base64, but fails to quote it, or provide any hints
> to the receiving JavaScript about what to do with the data.
> A typical message (from mobile spec, file.spec.86), ends up encoded like this:
> {code}
> cordova.callbackFromNative('File1615636988',true,1,[4oKsw6sgLSBUaGVyZSBpcyBhbiBleGNlcHRpb24gdG8gZXZlcnkgcnVsZS4gIEV4Y2VwdCB0aGlzIG9uZS5iaW46AQA=],false);
> {code}
> which immediately results in a syntax error when passed to the webview.
--
This message was sent by Atlassian JIRA
(v6.2#6252)