From b20ec58affc1e052f1980ddaedbd05eb59a5d7a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Tue, 23 Jun 2026 08:09:05 +0400 Subject: [PATCH] =?UTF-8?q?v1.0.120:=20fix=20ZIP=20=E2=80=94=20use=20FormD?= =?UTF-8?q?ata=20on=20client,=20parse=20multipart=20on=20VM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/convert_server.py | 26 ++++++++++++++++++++++++-- index.cfm | 5 ++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/deploy/convert_server.py b/deploy/convert_server.py index b7791a4..a2c0e0c 100755 --- a/deploy/convert_server.py +++ b/deploy/convert_server.py @@ -280,12 +280,34 @@ class Handler(BaseHTTPRequestHandler): def _handle_unzip_upload(self): """Распаковать ZIP и загрузить каждый файл в Lucee. Только файлы из корня архива.""" import zipfile, io + + # Читаем multipart form data + content_type = self.headers.get("Content-Type", "") length = int(self.headers.get("Content-Length", 0)) - data = self.rfile.read(length) + body = self.rfile.read(length) + + # Извлекаем ZIP из multipart + boundary = content_type.split("boundary=")[1].strip() + parts = body.split(b"--" + boundary.encode()) + zip_data = None + for part in parts: + if b"filename=" in part: + # Отделяем заголовки от тела + header_end = part.find(b"\r\n\r\n") + if header_end > 0: + zip_data = part[header_end+4:] + # Убираем trailing \r\n и boundary + if zip_data.endswith(b"\r\n"): + zip_data = zip_data[:-2] + break + + if not zip_data: + self.send_error(400, "no file in request") + return results = [] try: - with zipfile.ZipFile(io.BytesIO(data)) as zf: + with zipfile.ZipFile(io.BytesIO(zip_data)) as zf: for name in zf.namelist(): # Только файлы из корня (без папок), пропускаем директории if name.endswith('/') or '/' in name: diff --git a/index.cfm b/index.cfm index 424b1d6..14aef6f 100644 --- a/index.cfm +++ b/index.cfm @@ -75,7 +75,7 @@
Nubes - Сверка договоров — LLM AI-driven Event Sourcing v1.0.119 — Lucee + Сверка договоров — LLM AI-driven Event Sourcing v1.0.120 — Lucee
@@ -261,8 +261,7 @@ fileInput.addEventListener('change', async function() { try { var zipResp = await fetch(UNZIP_URL, { method: 'POST', - body: f, - headers: {'Content-Type': 'application/zip'} + body: (function() { var fd = new FormData(); fd.append('file', f); return fd; })() }); var zipData = await zipResp.json(); if (!zipData.ok || !zipData.files) throw new Error('unzip failed');