From 4fa28b0798aa27fd21247c77682758e396662ff0 Mon Sep 17 00:00:00 2001 From: liasica Date: Sun, 5 Jun 2022 00:41:27 +0800 Subject: [PATCH 1/3] 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; From 0f9896aedf5fd36ac7b2ebae21e89da1fad74bdd Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Thu, 13 Oct 2022 15:48:04 +0200 Subject: [PATCH 2/3] Update JavaScriptBridgeJS.java replaced js arrayBufferToString uint8Array.reduce arrow function with normal function --- .../plugin_scripts_js/JavaScriptBridgeJS.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f36fc042..d624eadb 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 @@ -148,7 +148,7 @@ public class JavaScriptBridgeJS { " }," + " arrayBufferToString: function(arrayBuffer) {" + " const uint8Array = new Uint8Array(arrayBuffer);" + - " const data = uint8Array.reduce((acc, i) => acc += String.fromCharCode.apply(null, [i]), '');" + + " const data = uint8Array.reduce(function(acc, i) { return acc += String.fromCharCode.apply(null, [i]); }, '');" + " return data;" + " }," + " isBodyFormData: function(bodyString) {" + From 4d41b1b4df403ef864713822d6cc95ed6fb526dd Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Thu, 13 Oct 2022 15:49:09 +0200 Subject: [PATCH 3/3] Update JavaScriptBridgeJS.swift replaced js arrayBufferToString uint8Array.reduce arrow function with normal function --- ios/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift b/ios/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift index 8f9aa385..3c65decc 100644 --- a/ios/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift +++ b/ios/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift @@ -176,7 +176,7 @@ let UTIL_JS_SOURCE = """ }, arrayBufferToString: function(arrayBuffer) { const uint8Array = new Uint8Array(arrayBuffer); - const data = uint8Array.reduce((acc, i) => acc += String.fromCharCode.apply(null, [i]), ''); + const data = uint8Array.reduce(function(acc, i) { return acc += String.fromCharCode.apply(null, [i]); }, ''); return data; }, isBodyFormData: function(bodyString) {