From 9c6e2ec0129ad26c2b973fe023bf398f97f09d8d Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 26 Aug 2021 23:23:56 +0200 Subject: [PATCH] misc modal rice and html escaping --- copyparty/web/browser.js | 6 +++--- copyparty/web/md.js | 2 +- copyparty/web/ui.css | 10 ++++++++++ copyparty/web/up2k.js | 12 ++++++------ copyparty/web/util.js | 8 +++++--- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index c4c308ef..ace0ebc1 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -2010,8 +2010,8 @@ var fileman = (function () { deleter(); } - modal.confirm('===== DANGER =====\nDELETE these ' + vps.length + ' items?\n\n' + uricom_adec(vps).join('\n'), function () { - modal.confirm('Last chance! Delete?', deleter, null); + modal.confirm('
DANGER
\nDELETE these ' + vps.length + ' items?', function () { + modal.confirm('Last chance! Delete?', deleter, null); }, null); }; @@ -2110,7 +2110,7 @@ var fileman = (function () { paster(); } - modal.confirm('paste these ' + req.length + ' items here?\n\n' + uricom_adec(req).join('\n'), function () { + modal.confirm('paste these ' + req.length + ' items here?', function () { paster(); jwrite('fman_clip', []); }, null); diff --git a/copyparty/web/md.js b/copyparty/web/md.js index e7c718e3..05713541 100644 --- a/copyparty/web/md.js +++ b/copyparty/web/md.js @@ -185,7 +185,7 @@ function md_plug_err(ex, js) { errbox.style.cssText = 'position:absolute;top:0;left:0;padding:1em .5em;background:#2b2b2b;color:#fc5' errbox.textContent = msg; errbox.onclick = function () { - modal.alert('
' + ex.stack + '
'); + modal.alert('
' + esc(ex.stack) + '
'); }; if (o) { errbox.appendChild(o); diff --git a/copyparty/web/ui.css b/copyparty/web/ui.css index 8c833ced..727f3093 100644 --- a/copyparty/web/ui.css +++ b/copyparty/web/ui.css @@ -165,6 +165,16 @@ html.light #tt em { min-width: 30em; } } +#modalc li { + margin: 1em 0; +} +#modalc h6 { + font-size: 1.3em; + border-bottom: 1px solid #999; + margin: 0; + padding: .3em; + text-align: center; +} #modalb { position: sticky; text-align: right; diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index bec6679f..fa121c5e 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -725,11 +725,11 @@ function up2k_init(subtle) { match = false; if (match) { - var msg = ['directory iterator got stuck on the following {0} items; good chance your browser is about to spinlock:'.format(missing.length)]; + var msg = ['directory iterator got stuck on the following {0} items; good chance your browser is about to spinlock:', function () { read_dirs(rd, [], [], good, bad, spins); }); } @@ -800,12 +800,12 @@ function up2k_init(subtle) { }); } - var msg = ['{0} these {1} files?'.format(fsearch ? 'search' : 'upload', good_files.length)]; + var msg = ['{0} these {1} files?', function () { up_them(good_files); }, null); up_them(good_files); } diff --git a/copyparty/web/util.js b/copyparty/web/util.js index 80696489..b24356d3 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -353,10 +353,12 @@ function uricom_dec(txt) { } -function uricom_adec(arr) { +function uricom_adec(arr, li) { var ret = []; - for (var a = 0; a < arr.length; a++) - ret.push(uricom_dec(arr[a])[0]); + for (var a = 0; a < arr.length; a++) { + var txt = uricom_dec(arr[a])[0]; + ret.push(li ? '
  • ' + esc(txt) + '
  • ' : txt); + } return ret; }