From 4fa28b0798aa27fd21247c77682758e396662ff0 Mon Sep 17 00:00:00 2001 From: liasica Date: Sun, 5 Jun 2022 00:41:27 +0800 Subject: [PATCH] Fix RangeError: Maximum call stack size exceeded --- .../plugin_scripts_js/JavaScriptBridgeJS.java | 4 +++- ios/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/JavaScriptBridgeJS.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/JavaScriptBridgeJS.java index 565a6120..f36fc042 100644 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/JavaScriptBridgeJS.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/plugin_scripts_js/JavaScriptBridgeJS.java @@ -147,7 +147,9 @@ public class JavaScriptBridgeJS { " });" + " }," + " arrayBufferToString: function(arrayBuffer) {" + - " return String.fromCharCode.apply(String, arrayBuffer);" + + " const uint8Array = new Uint8Array(arrayBuffer);" + + " const data = uint8Array.reduce((acc, i) => acc += String.fromCharCode.apply(null, [i]), '');" + + " return data;" + " }," + " isBodyFormData: function(bodyString) {" + " return bodyString.indexOf('------WebKitFormBoundary') >= 0;" + diff --git a/ios/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift b/ios/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift index 9aa6334d..8f9aa385 100644 --- a/ios/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift +++ b/ios/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift @@ -175,7 +175,9 @@ let UTIL_JS_SOURCE = """ }); }, arrayBufferToString: function(arrayBuffer) { - return String.fromCharCode.apply(String, arrayBuffer); + const uint8Array = new Uint8Array(arrayBuffer); + const data = uint8Array.reduce((acc, i) => acc += String.fromCharCode.apply(null, [i]), ''); + return data; }, isBodyFormData: function(bodyString) { return bodyString.indexOf('------WebKitFormBoundary') >= 0;