From 5677c5926109b5a95fb611b1fc29b238078829e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Wed, 19 Aug 2026 09:08:31 +0400 Subject: [PATCH] =?UTF-8?q?v0.0.35:=20=D0=BF=D1=80=D0=B8=20=D1=80=D0=B0?= =?UTF-8?q?=D1=81=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D0=B8=20ZIP=20=E2=80=94=20?= =?UTF-8?q?=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=B4=D0=BE=D0=BA=D1=83?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=82=D1=8B=20(pdf,=20doc,=20docx,=20txt,=20?= =?UTF-8?q?md),=20=D0=B8=D0=B7=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BF=D1=80=D0=BE=D0=BF=D1=83=D1=81=D0=BA=D0=B0?= =?UTF-8?q?=D1=8E=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- History/2026-08-19-zip-filter-docs.md | 38 +++++++++++++++++++++++++++ site/app.py | 2 +- site/templates/index.html | 8 ++++-- 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 History/2026-08-19-zip-filter-docs.md diff --git a/History/2026-08-19-zip-filter-docs.md b/History/2026-08-19-zip-filter-docs.md new file mode 100644 index 0000000..07af456 --- /dev/null +++ b/History/2026-08-19-zip-filter-docs.md @@ -0,0 +1,38 @@ +# v0.0.35 — фильтр документов при раскрытии ZIP — 2026-08-19 + +**Дата:** 2026-08-19 +**Версия:** 0.0.34 → 0.0.35 +**Файл:** `site/templates/index.html` (фронт `listZipFiles`), `site/app.py` (версия) + +--- + +## Суть + +При раскрытии ZIP в таблицу ранее вытаскивались ВСЕ файлы, включая изображения +(WhatsApp jpeg и т.п.). Теперь из ZIP извлекаются **только документы**: + +Разрешённые расширения: `.pdf`, `.doc`, `.docx`, `.txt`, `.md`. + +Всё прочее (jpeg, png, xls, exe и т.д.) — пропускается. Вложенные ZIP +раскрываются рекурсивно, и фильтр применяется и к их содержимому. + +## Изменение + +`listZipFiles()` в `index.html`: +```js +const allowedExt = ['.pdf', '.doc', '.docx', '.txt', '.md']; +... +else if (allowedExt.some(ext => low.endsWith(ext))) { + out.push(new File([e.data], e.name, { lastModified: e.dosMs })); +} +// иначе — не документ, пропускаем +``` + +## Проверка +- `node --check` — OK. +- Тест на архиве с `doc.pdf, old.doc, n.docx, a.txt, r.md, pic.jpeg, pic2.png`: + извлечены только 5 документов, jpeg/png пропущены — OK. + +## Вопрос (отложен) +- Нужно также упомянуть в подсказке на странице требование современного + браузера (`DecompressionStream`: Chrome 103+, Safari 16.4+, Firefox 113+). diff --git a/site/app.py b/site/app.py index 2ef5bb3..9cca547 100644 --- a/site/app.py +++ b/site/app.py @@ -20,7 +20,7 @@ if _sys_path_root not in sys.path: sys.path.insert(0, _sys_path_root) # Версия приложения (меняется при изменениях) -VERSION = "0.0.34" +VERSION = "0.0.35" def create_app(): diff --git a/site/templates/index.html b/site/templates/index.html index 6039ddc..97732ee 100644 --- a/site/templates/index.html +++ b/site/templates/index.html @@ -252,14 +252,18 @@ async function listZipFiles(file) { const buf = new Uint8Array(await file.arrayBuffer()); const entries = await parseZip(buf); const out = []; + // Из ZIP вытаскиваем только документы. Всё прочее (изображения и т.п.) пропускаем. + const allowedExt = ['.pdf', '.doc', '.docx', '.txt', '.md']; for (const e of entries) { if (e.isDir) continue; - if (e.name.toLowerCase().endsWith('.zip')) { + const low = e.name.toLowerCase(); + if (low.endsWith('.zip')) { const sub = new File([e.data], e.name, { lastModified: e.dosMs }); out.push(...(await listZipFiles(sub))); - } else { + } else if (allowedExt.some(ext => low.endsWith(ext))) { out.push(new File([e.data], e.name, { lastModified: e.dosMs })); } + // иначе — не документ, пропускаем } return out; }