loleaflet/src/core/Socket.js |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

New commits:
commit c511cc9fca8f1c650ab7104c4e2ca00a76bf38b8
Author: Henry Castro <hcas...@collabora.com>
Date:   Tue May 17 12:23:00 2016 -0400

    loleaflet: fix "Maximum call stack size exceeded"

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 606e137..bbd68e2 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -100,6 +100,14 @@ L.Socket = L.Class.extend({
                this._map._activate();
        },
 
+       _utf8ToString: function (data) {
+               var strBytes = '';
+               for (var it = 0; it < data.length; it++) {
+                       strBytes += String.fromCharCode(data[it]);
+               }
+               return strBytes;
+       },
+
        _onMessage: function (e) {
                var imgBytes, index, textMsg;
 
@@ -177,8 +185,13 @@ L.Socket = L.Class.extend({
                        // log the tile msg separately as we need the tile 
coordinates
                        L.Log.log(textMsg, L.INCOMING);
                        if (imgBytes !== undefined) {
-                               // if it's not a tile, parse the whole message
-                               textMsg = String.fromCharCode.apply(null, 
imgBytes);
+                               try {
+                                       // if it's not a tile, parse the whole 
message
+                                       textMsg = 
String.fromCharCode.apply(null, imgBytes);
+                               } catch (error) {
+                                       // big data string
+                                       textMsg = this._utf8ToString(imgBytes);
+                               }
                        }
                        // Decode UTF-8.
                        textMsg = decodeURIComponent(window.escape(textMsg));
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to