Reset picker status between selections and harden upload guards

This commit is contained in:
Repinoid
2026-10-24 08:31:19 +03:00
parent eb61a1b356
commit 3c0c3a2043
7 changed files with 48 additions and 10 deletions
+12 -2
View File
@@ -877,13 +877,23 @@
if (!sessionDone) ub.disabled = false;
}
function parseFilename(disp) {
if (!disp) return 'obfuscator.zip';
// RFC 5987: filename*=UTF-8''... имеет приоритет над обычным filename=.
const utf8 = disp.match(/filename\*=UTF-8''([^;]+)/i);
if (utf8) {
try { return decodeURIComponent(utf8[1]); } catch (e) { /* повреждённый percent-encoding */ }
}
const plain = disp.match(/filename="?([^";]+)"?/i);
return plain ? plain[1] : 'obfuscator.zip';
}
function downloadZip() {
if (!currentSid) return;
fetch('/api/download/' + currentSid)
.then(r => {
const disp = r.headers.get('Content-Disposition');
const m = disp && disp.match(/filename="?(.+?)"?$/);
return Promise.all([r.blob(), m ? m[1] : 'obfuscator.zip']);
return Promise.all([r.blob(), parseFilename(disp)]);
})
.then(([blob, fname]) => {
const a = document.createElement('a');