Skip to content

Commit 900d589

Browse files
Philip GuoPhilip Guo
authored andcommitted
try to prevent out-of-control long URLs
1 parent 560e05a commit 900d589

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

‎v3/js/opt-frontend-common.js‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,7 @@ function genericOptFrontendReady() {
10061006
// message and give up.
10071007
if (num414Tries === 0) {
10081008
num414Tries++;
1009+
startExecutingCode(); // TODO: does this work?
10091010
$("#executeBtn").click();
10101011
} else {
10111012
num414Tries = 0;
@@ -1611,6 +1612,24 @@ function executeCodeAndCreateViz(codeToExec,
16111612
jsonp_endpoint = CPP_JSONP_ENDPOINT;
16121613
}
16131614

1615+
// if we don't have any deltas, then don't bother sending deltaObj:
1616+
var deltaObjStringified = (deltaObj && (deltaObj.deltas.length > 0)) ? JSON.stringify(deltaObj) : null;
1617+
if (deltaObjStringified) {
1618+
// if deltaObjStringified is too long, then that will likely make
1619+
// the URL way too long. in that case, just make it null and don't
1620+
// send a delta. we'll lose some info but at least the URL will
1621+
// hopefully not overflow:
1622+
if (deltaObjStringified.length > 4096) {
1623+
console.log('deltaObjStringified.length:', deltaObjStringified.length, '| too long, so set to null');
1624+
deltaObjStringified = null;
1625+
} else {
1626+
console.log('deltaObjStringified.length:', deltaObjStringified.length);
1627+
}
1628+
} else {
1629+
console.log('deltaObjStringified is null');
1630+
}
1631+
1632+
16141633
if (backendScript === js_backend_script ||
16151634
backendScript === ts_backend_script ||
16161635
backendScript === java_backend_script ||
@@ -1623,8 +1642,7 @@ function executeCodeAndCreateViz(codeToExec,
16231642
options_json: JSON.stringify(backendOptionsObj),
16241643
user_uuid: supports_html5_storage() ? localStorage.getItem('opt_uuid') : undefined,
16251644
session_uuid: sessionUUID,
1626-
// if we don't have any deltas, then don't bother sending deltaObj:
1627-
diffs_json: deltaObj && (deltaObj.deltas.length > 0) ? JSON.stringify(deltaObj) : null},
1645+
diffs_json: deltaObjStringified},
16281646
function(dat) {} /* don't do anything since this is a dummy call */, "text");
16291647

16301648
// the REAL call uses JSONP
@@ -1647,8 +1665,7 @@ function executeCodeAndCreateViz(codeToExec,
16471665
options_json: JSON.stringify(backendOptionsObj),
16481666
user_uuid: supports_html5_storage() ? localStorage.getItem('opt_uuid') : undefined,
16491667
session_uuid: sessionUUID,
1650-
// if we don't have any deltas, then don't bother sending deltaObj:
1651-
diffs_json: deltaObj && (deltaObj.deltas.length > 0) ? JSON.stringify(deltaObj) : null},
1668+
diffs_json: deltaObjStringified},
16521669
execCallback, "json");
16531670
}
16541671

0 commit comments

Comments
 (0)