From b872df0f314194ad50cbaa098ebbf717e53bb354 Mon Sep 17 00:00:00 2001 From: Ian Clelland Date: Wed, 2 Apr 2014 12:08:27 -0400 Subject: [PATCH] CB-6388: Handle binary data correctly in LOAD_URL bridge --- .../cordova/NativeToJsMessageQueue.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java index 5ee74f53..5d0c061b 100755 --- a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java +++ b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java @@ -494,9 +494,22 @@ public class NativeToJsMessageQueue { .append(success) .append(",") .append(status) - .append(",[") - .append(pluginResult.getMessage()) - .append("],") + .append(",["); + switch (pluginResult.getMessageType()) { + case PluginResult.MESSAGE_TYPE_BINARYSTRING: + sb.append("atob('") + .append(pluginResult.getMessage()) + .append("')"); + break; + case PluginResult.MESSAGE_TYPE_ARRAYBUFFER: + sb.append("cordova.require('cordova/base64').toArrayBuffer('") + .append(pluginResult.getMessage()) + .append("')"); + break; + default: + sb.append(pluginResult.getMessage()); + } + sb.append("],") .append(pluginResult.getKeepCallback()) .append(");"); }