From 42ea30270f320d53cd24fd479086f36ed3d3f25f Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 16 Aug 2021 08:16:52 +0200 Subject: [PATCH] up2k-ui: post absolute URLs --- README.md | 8 ++++---- copyparty/web/up2k.js | 17 +++++++++-------- copyparty/web/util.js | 10 ++++++++++ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c5a2c1f0..e9ad10a7 100644 --- a/README.md +++ b/README.md @@ -585,14 +585,14 @@ copyparty can invoke external programs to collect additional metadata for files | browse files | yep | yep | yep | yep | yep | yep | yep | yep | | thumbnail view | - | yep | yep | yep | yep | yep | yep | yep | | basic uploader | yep | yep | yep | yep | yep | yep | yep | yep | -| up2k | - | - | - | - | yep | yep | yep | yep | +| up2k | - | - | `*1` | `*1` | yep | yep | yep | yep | | make directory | yep | yep | yep | yep | yep | yep | yep | yep | | send message | yep | yep | yep | yep | yep | yep | yep | yep | | set sort order | - | yep | yep | yep | yep | yep | yep | yep | | zip selection | - | yep | yep | yep | yep | yep | yep | yep | | file rename | - | yep | yep | yep | yep | yep | yep | yep | | file cut/paste | - | yep | yep | yep | yep | yep | yep | yep | -| navpane | - | `*1` | `*2` | yep | yep | yep | yep | yep | +| navpane | - | `*2` | yep | yep | yep | yep | yep | yep | | image viewer | - | yep | yep | yep | yep | yep | yep | yep | | video player | - | yep | yep | yep | yep | yep | yep | yep | | markdown editor | - | - | yep | yep | yep | yep | yep | yep | @@ -603,8 +603,8 @@ copyparty can invoke external programs to collect additional metadata for files * internet explorer 6 to 8 behave the same * firefox 52 and chrome 49 are the last winxp versions -* `*1` causes a full-page refresh on each navigation -* `*2` only public folders (login session is dropped) and no history / back-button +* `*1` yes, but extremely slow (ie10: 1 MiB/s, ie11: 270 KiB/s) +* `*2` causes a full-page refresh on each navigation * `*3` using a wasm decoder which can sometimes get stuck and consumes a bit more power quick summary of more eccentric web-browsers trying to view a directory index: diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index 444ed9ad..ffaeb42b 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -511,7 +511,7 @@ function up2k_init(subtle) { import_js('/.cpr/deps/' + fn, unmodal); if (is_https) - ebi('u2foot').innerHTML = shame + ' so this uploader will do like 500kB/s at best'; + ebi('u2foot').innerHTML = shame + ' so this uploader will do like 500 KiB/s at best'; else ebi('u2foot').innerHTML = 'seems like ' + shame + ' so do that if you want more performance (expecting 20' : '8a5">(but dont worry too much, expect 100') + ' MiB/s)'; @@ -805,13 +805,13 @@ function up2k_init(subtle) { for (var a = 0; a < good_files.length; a++) { var fobj = good_files[a][0], name = good_files[a][1], - fdir = '', + fdir = get_evpath(), now = Date.now(), lmod = fobj.lastModified || now, ofs = name.lastIndexOf('/') + 1; if (ofs) { - fdir = name.slice(0, ofs); + fdir += url_enc(name.slice(0, ofs)); name = name.slice(ofs); } @@ -1263,7 +1263,7 @@ function up2k_init(subtle) { try { orz(e); } catch (ex) { vis_exh(ex + '', '', '', '', ex); } }; - xhr.open('HEAD', t.purl + t.name, true); + xhr.open('HEAD', t.purl + uricom_enc(t.name), true); xhr.send(); } @@ -1340,12 +1340,13 @@ function up2k_init(subtle) { return; } - if (response.purl !== t.purl || response.name !== t.name) { + var rsp_purl = url_enc(response.purl); + if (rsp_purl !== t.purl || response.name !== t.name) { // server renamed us (file exists / path restrictions) - console.log("server-rename [" + t.purl + "] [" + t.name + "] to [" + response.purl + "] [" + response.name + "]"); - t.purl = response.purl; + console.log("server-rename [" + t.purl + "] [" + t.name + "] to [" + rsp_purl + "] [" + response.name + "]"); + t.purl = rsp_purl; t.name = response.name; - pvis.seth(t.n, 0, linksplit(t.purl + t.name).join(' ')); + pvis.seth(t.n, 0, linksplit(uricom_dec(t.purl)[0] + t.name).join(' ')); } var chunksize = get_chunksize(t.size), diff --git a/copyparty/web/util.js b/copyparty/web/util.js index 44ff15cd..fc6efcfa 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -331,6 +331,16 @@ function uricom_enc(txt, do_fb_enc) { } } +function url_enc(txt) { + var parts = txt.split('/'), + ret = []; + + for (var a = 0; a < parts.length; a++) + ret.push(uricom_enc(parts[a])); + + return ret.join('/'); +} + function uricom_dec(txt) { try {