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 @@