mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Fix crash due to JSON.stringify on a cirular structure in injectes js.
This commit is contained in:
+19
-1
@@ -54,10 +54,28 @@ class WebViewWidgetMessageInterceptor(
|
|||||||
// objects in log lines.
|
// objects in log lines.
|
||||||
view.evaluateJavascript(
|
view.evaluateJavascript(
|
||||||
"""
|
"""
|
||||||
|
// Removing any parts that result in a circular structure. Circular structures crash JSON.stringify.
|
||||||
|
function simpleStringify(object) {
|
||||||
|
const simpleObject = {};
|
||||||
|
for (const prop in object) {
|
||||||
|
if (!object.hasOwnProperty(prop)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (typeof(object[prop]) == 'object') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (typeof(object[prop]) == 'function') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
simpleObject[prop] = object[prop];
|
||||||
|
}
|
||||||
|
return JSON.stringify(simpleObject);
|
||||||
|
}
|
||||||
|
|
||||||
function logFn(consoleLogFn, ...args) {
|
function logFn(consoleLogFn, ...args) {
|
||||||
consoleLogFn(
|
consoleLogFn(
|
||||||
args.map(
|
args.map(
|
||||||
a => typeof a === "string" ? a : JSON.stringify(a)
|
a => typeof a === "string" ? a : simpleStringify(a)
|
||||||
).join(' ')
|
).join(' ')
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user