-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into agg23/FirefoxSearchShortcut
- Loading branch information
Showing
9 changed files
with
262 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
diff --git a/node_modules/socket.io-parser/dist/binary.js b/node_modules/socket.io-parser/dist/binary.js | ||
index a908023..99e0215 100644 | ||
--- a/node_modules/socket.io-parser/dist/binary.js | ||
+++ b/node_modules/socket.io-parser/dist/binary.js | ||
@@ -13,12 +13,12 @@ function deconstructPacket(packet) { | ||
const buffers = []; | ||
const packetData = packet.data; | ||
const pack = packet; | ||
- pack.data = _deconstructPacket(packetData, buffers); | ||
+ pack.data = _deconstructPacket(packetData, buffers, [], new WeakMap()); | ||
pack.attachments = buffers.length; // number of binary 'attachments' | ||
return { packet: pack, buffers: buffers }; | ||
} | ||
exports.deconstructPacket = deconstructPacket; | ||
-function _deconstructPacket(data, buffers) { | ||
+function _deconstructPacket(data, buffers, known, retvals) { | ||
if (!data) | ||
return data; | ||
if (is_binary_1.isBinary(data)) { | ||
@@ -26,18 +26,27 @@ function _deconstructPacket(data, buffers) { | ||
buffers.push(data); | ||
return placeholder; | ||
} | ||
- else if (Array.isArray(data)) { | ||
+ else if (retvals.has(data)) { | ||
+ return retvals.get(data) | ||
+ } | ||
+ else if (known.includes(data)) { | ||
+ return data; | ||
+ } | ||
+ known.push(data) | ||
+ if (Array.isArray(data)) { | ||
const newData = new Array(data.length); | ||
+ retvals.set(data, newData) | ||
for (let i = 0; i < data.length; i++) { | ||
- newData[i] = _deconstructPacket(data[i], buffers); | ||
+ newData[i] = _deconstructPacket(data[i], buffers, known, retvals); | ||
} | ||
return newData; | ||
} | ||
else if (typeof data === "object" && !(data instanceof Date)) { | ||
const newData = {}; | ||
+ retvals.set(data, newData) | ||
for (const key in data) { | ||
- if (data.hasOwnProperty(key)) { | ||
- newData[key] = _deconstructPacket(data[key], buffers); | ||
+ if (Object.prototype.hasOwnProperty.call(data, key)) { | ||
+ newData[key] = _deconstructPacket(data[key], buffers, known, retvals); | ||
} | ||
} | ||
return newData; | ||
@@ -53,26 +62,29 @@ function _deconstructPacket(data, buffers) { | ||
* @public | ||
*/ | ||
function reconstructPacket(packet, buffers) { | ||
- packet.data = _reconstructPacket(packet.data, buffers); | ||
+ packet.data = _reconstructPacket(packet.data, buffers, []); | ||
packet.attachments = undefined; // no longer useful | ||
return packet; | ||
} | ||
exports.reconstructPacket = reconstructPacket; | ||
-function _reconstructPacket(data, buffers) { | ||
+function _reconstructPacket(data, buffers, known) { | ||
if (!data) | ||
return data; | ||
if (data && data._placeholder) { | ||
return buffers[data.num]; // appropriate buffer (should be natural order anyway) | ||
+ } else if (known.includes(data)) { | ||
+ return data | ||
} | ||
- else if (Array.isArray(data)) { | ||
+ known.push(data) | ||
+ if (Array.isArray(data)) { | ||
for (let i = 0; i < data.length; i++) { | ||
- data[i] = _reconstructPacket(data[i], buffers); | ||
+ data[i] = _reconstructPacket(data[i], buffers, known); | ||
} | ||
} | ||
else if (typeof data === "object") { | ||
for (const key in data) { | ||
if (data.hasOwnProperty(key)) { | ||
- data[key] = _reconstructPacket(data[key], buffers); | ||
+ data[key] = _reconstructPacket(data[key], buffers, known); | ||
} | ||
} | ||
} | ||
diff --git a/node_modules/socket.io-parser/dist/index.js b/node_modules/socket.io-parser/dist/index.js | ||
index 0ef9f80..4cd787e 100644 | ||
--- a/node_modules/socket.io-parser/dist/index.js | ||
+++ b/node_modules/socket.io-parser/dist/index.js | ||
@@ -5,6 +5,7 @@ const Emitter = require("component-emitter"); | ||
const binary_1 = require("./binary"); | ||
const is_binary_1 = require("./is-binary"); | ||
const debug = require("debug")("socket.io-parser"); | ||
+const CircularJSON = require('circular-json') | ||
/** | ||
* Protocol version. | ||
* | ||
@@ -66,7 +67,7 @@ class Encoder { | ||
} | ||
// json data | ||
if (null != obj.data) { | ||
- str += JSON.stringify(obj.data); | ||
+ str += CircularJSON.stringify(obj.data); | ||
} | ||
debug("encoded %j as %s", obj, str); | ||
return str; | ||
@@ -232,7 +233,7 @@ class Decoder extends Emitter { | ||
exports.Decoder = Decoder; | ||
function tryParse(str) { | ||
try { | ||
- return JSON.parse(str); | ||
+ return CircularJSON.parse(str); | ||
} | ||
catch (e) { | ||
return false; | ||
diff --git a/node_modules/socket.io-parser/dist/is-binary.js b/node_modules/socket.io-parser/dist/is-binary.js | ||
index 4b7c234..95469f7 100644 | ||
--- a/node_modules/socket.io-parser/dist/is-binary.js | ||
+++ b/node_modules/socket.io-parser/dist/is-binary.js | ||
@@ -1,6 +1,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hasBinary = exports.isBinary = void 0; | ||
+const withNativeBuffer = typeof Buffer === 'function' && typeof Buffer.isBuffer === 'function'; | ||
const withNativeArrayBuffer = typeof ArrayBuffer === "function"; | ||
const isView = (obj) => { | ||
return typeof ArrayBuffer.isView === "function" | ||
@@ -22,13 +23,18 @@ const withNativeFile = typeof File === "function" || | ||
function isBinary(obj) { | ||
return ((withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))) || | ||
(withNativeBlob && obj instanceof Blob) || | ||
- (withNativeFile && obj instanceof File)); | ||
+ (withNativeFile && obj instanceof File)) || | ||
+ (withNativeBuffer && Buffer.isBuffer(obj)); | ||
} | ||
exports.isBinary = isBinary; | ||
-function hasBinary(obj, toJSON) { | ||
+function hasBinary(obj, known = []) { | ||
if (!obj || typeof obj !== "object") { | ||
return false; | ||
} | ||
+ if (known.includes(obj)) { | ||
+ return false | ||
+ } | ||
+ known.push(obj) | ||
if (Array.isArray(obj)) { | ||
for (let i = 0, l = obj.length; i < l; i++) { | ||
if (hasBinary(obj[i])) { | ||
@@ -43,10 +49,10 @@ function hasBinary(obj, toJSON) { | ||
if (obj.toJSON && | ||
typeof obj.toJSON === "function" && | ||
arguments.length === 1) { | ||
- return hasBinary(obj.toJSON(), true); | ||
+ return hasBinary(obj.toJSON(), known); | ||
} | ||
for (const key in obj) { | ||
- if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) { | ||
+ if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key], known)) { | ||
return true; | ||
} | ||
} |
Oops, something went wrong.