From 1e114ddaa88b3fc233c0222207666f4fa960974b Mon Sep 17 00:00:00 2001 From: Martha Cryan Date: Thu, 18 Jun 2026 19:33:40 -0700 Subject: [PATCH 1/3] Add origin as query string to requests to plotlyServerURL --- src/plots/plots.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plots/plots.js b/src/plots/plots.js index d86c5c7e06b..43227690209 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -213,7 +213,12 @@ plots.sendDataToCloud = function(gd, serverURL) { // Open the Cloud login page in a new tab. We keep a reference so we can post // the chart back to it once Cloud reports that authentication succeeded. - var cloudWindow = window.open(serverURL, '_blank'); + // Pass the current page's origin as a query string so Cloud knows where to + // send the CHART_AUTH_SUCCESS message back to. + var uploadUrl = serverURL + + (serverURL.indexOf('?') === -1 ? '?' : '&') + + 'origin=' + encodeURIComponent(window.location.origin); + var cloudWindow = window.open(uploadUrl, '_blank'); if(!cloudWindow) { console.error('Unable to open Plotly Cloud (the popup may have been blocked)'); gd.emit('plotly_exportfail'); From a26650b4338e2a3258f46192e6479f26cf25eb7e Mon Sep 17 00:00:00 2001 From: Martha Cryan Date: Tue, 23 Jun 2026 18:33:00 -0700 Subject: [PATCH 2/3] Update to use built-in APIs instead of hard-coding query strings --- src/plots/plots.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/plots/plots.js b/src/plots/plots.js index 43227690209..4bfefec3cef 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -215,10 +215,9 @@ plots.sendDataToCloud = function(gd, serverURL) { // the chart back to it once Cloud reports that authentication succeeded. // Pass the current page's origin as a query string so Cloud knows where to // send the CHART_AUTH_SUCCESS message back to. - var uploadUrl = serverURL + - (serverURL.indexOf('?') === -1 ? '?' : '&') + - 'origin=' + encodeURIComponent(window.location.origin); - var cloudWindow = window.open(uploadUrl, '_blank'); + var uploadUrl = new URL(serverURL); + uploadUrl.searchParams.set('origin', window.location.origin); + var cloudWindow = window.open(uploadUrl.href, '_blank'); if(!cloudWindow) { console.error('Unable to open Plotly Cloud (the popup may have been blocked)'); gd.emit('plotly_exportfail'); From d5f4789661cd14190d9246ab253d9258ae37e9ab Mon Sep 17 00:00:00 2001 From: Emily KL <4672118+emilykl@users.noreply.github.com> Date: Tue, 30 Jun 2026 12:54:21 -0400 Subject: [PATCH 3/3] update Jasmine test --- draftlogs/7802_change.md | 2 +- test/jasmine/tests/config_test.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/draftlogs/7802_change.md b/draftlogs/7802_change.md index ccbd4d58ead..e1e372d23eb 100644 --- a/draftlogs/7802_change.md +++ b/draftlogs/7802_change.md @@ -1,2 +1,2 @@ -- Update `sendDataToCloud` modebar button to upload chart to Plotly Cloud [[#7802](https://github.com/plotly/plotly.js/pull/7802), [#7852](https://github.com/plotly/plotly.js/pull/7852)] +- Update `sendDataToCloud` modebar button to upload chart to Plotly Cloud [[#7802](https://github.com/plotly/plotly.js/pull/7802), [#7852](https://github.com/plotly/plotly.js/pull/7852), [#7854](https://github.com/plotly/plotly.js/pull/7854)] - NOTE: The Plotly Cloud endpoint for receiving charts is not yet functional, so this button won't complete the upload. diff --git a/test/jasmine/tests/config_test.js b/test/jasmine/tests/config_test.js index 41514e68bb1..5304e74346c 100644 --- a/test/jasmine/tests/config_test.js +++ b/test/jasmine/tests/config_test.js @@ -585,8 +585,9 @@ describe('config argument', function() { expect(confirmBtn).not.toBe(null, 'confirm button should be shown'); mouseEvent('click', 0, 0, {element: confirmBtn}); - // Should open the provided URL's origin in a new tab - expect(openSpy).toHaveBeenCalledWith('https://example.plotly.com/endpoint', '_blank'); + // Should open the provided URL's origin in a new tab, + // adding the current page's origin as a query parameter + expect(openSpy).toHaveBeenCalledWith('https://example.plotly.com/endpoint?origin=http%3A%2F%2Flocalhost%3A9876', '_blank'); }) .then(done, done.fail); });