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); }