瀏覽代碼

Robustness fix for clients returning weird stuff in the message data

Jørgen Orehøj Erichsen 6 年之前
父節點
當前提交
0f9f8b4706
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4
    0
      autoHeightWebView/index.android.js

+ 4
- 0
autoHeightWebView/index.android.js 查看文件

217
     if (!e.nativeEvent) {
217
     if (!e.nativeEvent) {
218
       return;
218
       return;
219
     }
219
     }
220
+    
221
+    // Sometimes the message is invalid JSON, so we ignore that case
222
+    try { JSON.parse(isBelowKitKat ? e.nativeEvent.message : e.nativeEvent.data) } catch(e) { return }
223
+
220
     const { height, width } = JSON.parse(isBelowKitKat ? e.nativeEvent.message : e.nativeEvent.data);
224
     const { height, width } = JSON.parse(isBelowKitKat ? e.nativeEvent.message : e.nativeEvent.data);
221
     const { height: oldHeight, width: oldWidth } = this.state;
225
     const { height: oldHeight, width: oldWidth } = this.state;
222
     if (isSizeChanged(height, oldHeight, width, oldWidth)) {
226
     if (isSizeChanged(height, oldHeight, width, oldWidth)) {