Reset picker status between selections and harden upload guards
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user