From 023dba3daad456b206116e9057226810835beb68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Mon, 24 Aug 2026 15:46:24 +0300 Subject: [PATCH] =?UTF-8?q?v0.0.67:=20=D1=84=D0=B8=D0=BA=D1=81=20=D0=BA?= =?UTF-8?q?=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=D0=B8=D1=87=D0=B5=D1=81=D0=BA?= =?UTF-8?q?=D0=B8=D1=85=20=D0=B8=D0=BC=D1=91=D0=BD=20=D0=B8=D0=B7=20ZIP=20?= =?UTF-8?q?(UTF-8=20=D0=B1=D0=B5=D0=B7=20=D1=84=D0=BB=D0=B0=D0=B3=D0=B0=20?= =?UTF-8?q?->=20=D0=BC=D1=83=D1=81=D0=BE=D1=80=20CP866)=20=E2=80=94=20?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=BE=D0=B3=D0=B0=D1=8F=20UTF-8=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B0=20=D0=B2=20decodeZip?= =?UTF-8?q?Name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site/app.py | 2 +- site/templates/index.html | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/site/app.py b/site/app.py index 091cf5c..8bc5576 100644 --- a/site/app.py +++ b/site/app.py @@ -21,7 +21,7 @@ if _sys_path_root not in sys.path: sys.path.insert(0, _sys_path_root) # Версия приложения (меняется при изменениях) -VERSION = "0.0.66" +VERSION = "0.0.67" def setup_logging(): diff --git a/site/templates/index.html b/site/templates/index.html index 495689a..2a77d17 100644 --- a/site/templates/index.html +++ b/site/templates/index.html @@ -405,6 +405,14 @@ function dosToMs(date, time) { function decodeZipName(bytes, isUtf8) { if (isUtf8) return new TextDecoder('utf-8').decode(bytes); + // Многие архиваторы пишут имя в UTF-8, но НЕ выставляют UTF-8-флаг (bit 11). + // Сначала строго пробуем UTF-8: если байты — валидный UTF-8 с кириллицей/текстом, + // берём их как есть (иначе декодирование CP437→CP866 превратит их в «╨╣…»-мусор). + try { + const s = new TextDecoder('utf-8', { fatal: true }).decode(bytes); + // Кириллица — точно UTF-8; либо чистый печатаемый текст без управляющих символов. + if (/[\u0400-\u04FF]/.test(s) || !/[^\u0020-\u007e]/.test(s)) return s; + } catch (e) { /* не UTF-8 — legacy (CP437/CP866) */ } let name; try { name = new TextDecoder('ibm437').decode(bytes); } catch (e) { name = new TextDecoder('utf-8').decode(bytes); }