From 6b0f88e1afdb981f1098b6f0df455962911b3aa7 Mon Sep 17 00:00:00 2001 From: Ben Schwartz Date: Mon, 5 Dec 2016 18:04:14 -0500 Subject: [PATCH 1/2] Accept both levels of invite escaping Currently only double-escaped invites are supported. --- src/cca/scripts/uproxy_server.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cca/scripts/uproxy_server.ts b/src/cca/scripts/uproxy_server.ts index 6c6b6dee99..0c64b3c2ed 100644 --- a/src/cca/scripts/uproxy_server.ts +++ b/src/cca/scripts/uproxy_server.ts @@ -90,8 +90,11 @@ export class UproxyServerRepository implements ServerRepository { return Promise.reject(new Error('could not decode URL')); } - const cloudTokens: cloud_social_provider.Invite = JSON.parse( - jsurl.parse(params.networkData)); + params.networkData = jsurl.parse(params.networkData); + const cloudTokens: cloud_social_provider.Invite = + typeof params.networkData === 'string' ? + JSON.parse(params.networkData) : + params.networkData; this.saveServer(cloudTokens); // TODO: only notify the core when connecting, and delete it afterwards return this.notifyCoreOfServer(cloudTokens); From 3057e150dd49f13f962787543e02bb980b909e6d Mon Sep 17 00:00:00 2001 From: Ben Schwartz Date: Tue, 6 Dec 2016 10:10:48 -0500 Subject: [PATCH 2/2] Add a comment explaining the URL parsing code. --- src/cca/scripts/uproxy_server.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cca/scripts/uproxy_server.ts b/src/cca/scripts/uproxy_server.ts index 0c64b3c2ed..84cced1ce3 100644 --- a/src/cca/scripts/uproxy_server.ts +++ b/src/cca/scripts/uproxy_server.ts @@ -91,6 +91,9 @@ export class UproxyServerRepository implements ServerRepository { } params.networkData = jsurl.parse(params.networkData); + // Due to a gradual transition to the new URL format, some older invites + // are actually jsurl(JSON(cloudTokens)), instead of just + // jsurl(cloudTokens). This conditional ensures we parse both forms. const cloudTokens: cloud_social_provider.Invite = typeof params.networkData === 'string' ? JSON.parse(params.networkData) :