From a3efc4c726085a509af20b25f7c6657e446a59b8 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 22 Nov 2021 21:53:23 +0100 Subject: [PATCH] encode quoted queries into raw --- copyparty/u2idx.py | 3 +-- copyparty/web/browser.js | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/copyparty/u2idx.py b/copyparty/u2idx.py index 557c9107..e93398b2 100644 --- a/copyparty/u2idx.py +++ b/copyparty/u2idx.py @@ -122,8 +122,7 @@ class U2idx(object): while v.endswith("\\"): v2, uq = uq.split('"', 1) v = v[:-1] + '"' + v2 - v2, uq = (uq + " ").split(" ", 1) - v += v2 + uq = uq.strip() else: v, uq = (uq + " ").split(" ", 1) v = v.replace('\\"', '"') diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index e9cecdaa..eb761d1b 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -3234,7 +3234,34 @@ document.onkeydown = function (e) { for (var b = 1; b < sconf[a].length; b++) { var k = sconf[a][b][0], chk = 'srch_' + k + 'c', - tvs = ebi('srch_' + k + 'v').value.split(/ +/g); + vs = ebi('srch_' + k + 'v').value, + tvs = []; + + if (k == 'name') + console.log('a'); + while (vs) { + vs = vs.trim(); + if (!vs) + break; + + var v = ''; + if (vs.startsWith('"')) { + var vp = vs.slice(1).split(/"(.*)/); + v = vp[0]; + vs = vp[1] || ''; + while (v.endsWith('\\')) { + vp = vs.split(/"(.*)/); + v = v.slice(0, -1) + '"' + vp[0]; + vs = vp[1] || ''; + } + } + else { + var vp = vs.split(/ +(.*)/); + v = vp[0].replace(/\\"/g, '"'); + vs = vp[1] || ''; + } + tvs.push(v); + } if (!ebi(chk).checked) continue; @@ -3277,6 +3304,10 @@ document.onkeydown = function (e) { tv += '*'; } + if (tv.indexOf(' ') + 1) { + tv = '"' + tv + '"'; + } + q += k + not + 'like ' + tv; } }