Skip to content

Commit

Permalink
Merge branch 'develop' into agg23/FirefoxSearchShortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
agg23 authored May 6, 2021
2 parents 9be6f68 + 8f68d4e commit 9a9f984
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 169 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
"**/@types/react": "16.9.50",
"**/jquery": "3.1.1",
"**/pretty-format": "26.4.0",
"**/socket.io-parser": "4.0.2",
"**/socket.io-parser": "4.0.4",
"vue-template-compiler": "2.6.12"
}
}
9 changes: 9 additions & 0 deletions packages/driver/cypress/integration/cypress/utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ describe('driver/src/cypress/utils', () => {
it('symbol', function () {
expect(this.str(Symbol.iterator)).to.eq('Symbol')
})

it('circular', function () {
const obj = {}

obj.obj = obj

// at this point, there is no special formatting for a circular object, we simply fall back to String() on recursion failure
expect(this.str(obj)).to.be.a.string
})
})

context('Arrays', () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/driver/src/cypress/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ module.exports = {
return `Object{${len}}`
}

return this.stringifyActualObj(value)
try {
return this.stringifyActualObj(value)
} catch (err) {
return String(value)
}
}

if (_.isSymbol(value)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/app/client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { client } from '@packages/socket/lib/browser'

export const connect = (host, path, extraOpts = {}) => {
return client.io(host, {
return client(host, {
path,
transports: ['websocket'],
...extraOpts,
Expand Down
4 changes: 2 additions & 2 deletions packages/socket/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"dependencies": {
"circular-json": "0.5.9",
"socket.io": "3.0.4",
"socket.io-client": "3.0.4"
"socket.io": "4.0.1",
"socket.io-client": "4.0.1"
},
"devDependencies": {
"chai": "3.5.0",
Expand Down
122 changes: 0 additions & 122 deletions packages/socket/patches/socket.io-parser+4.0.2.patch

This file was deleted.

162 changes: 162 additions & 0 deletions packages/socket/patches/socket.io-parser+4.0.4.patch
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;
}
}
Loading

0 comments on commit 9a9f984

Please sign in to comment.