mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
detect reverse-proxies stripping URL params:
if a reverseproxy decides to strip away URL parameters, show an appropriate error-toast instead of silently entering a bad state someone on discord ended up in an infinite page-reload loop since the js would try to recover by fully navigating to the requested dir if `?ls` failed, which wouldn't do any good anyways if the dir in question is the initial dir to display
This commit is contained in:
parent
cab999978e
commit
136c0fdc2b
|
@ -5830,7 +5830,7 @@ var treectl = (function () {
|
|||
var res = JSON.parse(this.responseText);
|
||||
}
|
||||
catch (ex) {
|
||||
return;
|
||||
return toast.err(30, "bad <code>?tree</code> reply;\nexpected json, got this:\n\n" + esc(this.responseText + ''));
|
||||
}
|
||||
rendertree(res, this.ts, this.top, this.dst, this.rst);
|
||||
}
|
||||
|
@ -5995,7 +5995,7 @@ var treectl = (function () {
|
|||
thegrid.setvis(true);
|
||||
}
|
||||
|
||||
r.reqls = function (url, hpush, back) {
|
||||
r.reqls = function (url, hpush, back, hydrate) {
|
||||
if (IE && !history.pushState)
|
||||
return window.location = url;
|
||||
|
||||
|
@ -6003,6 +6003,7 @@ var treectl = (function () {
|
|||
xhr.top = url.split('?')[0];
|
||||
xhr.back = back
|
||||
xhr.hpush = hpush;
|
||||
xhr.hydrate = hydrate;
|
||||
xhr.ts = Date.now();
|
||||
xhr.open('GET', xhr.top + '?ls' + (r.dots ? '&dots' : ''), true);
|
||||
xhr.onload = xhr.onerror = recvls;
|
||||
|
@ -6049,8 +6050,10 @@ var treectl = (function () {
|
|||
var res = JSON.parse(this.responseText);
|
||||
}
|
||||
catch (ex) {
|
||||
if (!this.hydrate)
|
||||
location = this.top;
|
||||
return;
|
||||
|
||||
return toast.err(30, "bad <code>?ls</code> reply;\nexpected json, got this:\n\n" + esc(this.responseText + ''));
|
||||
}
|
||||
|
||||
if (r.chk_index_html(this.top, res))
|
||||
|
@ -6272,7 +6275,7 @@ var treectl = (function () {
|
|||
xhr.send();
|
||||
|
||||
r.ls_cb = showfile.addlinks;
|
||||
return r.reqls(get_evpath(), false);
|
||||
return r.reqls(get_evpath(), false, undefined, true);
|
||||
}
|
||||
|
||||
var top = get_evpath();
|
||||
|
|
|
@ -1470,6 +1470,8 @@ var toast = (function () {
|
|||
};
|
||||
|
||||
r.show = function (cl, sec, txt, tag) {
|
||||
txt = (txt + '').slice(0, 16384);
|
||||
|
||||
var same = r.visible && txt == r.p_txt && r.p_sec == sec,
|
||||
delta = Date.now() - r.p_t;
|
||||
|
||||
|
|
Loading…
Reference in a new issue