From 4adf3083f3152ab7b92250ff5dadce5fc4c8ffc8 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sun, 1 Nov 2026 01:06:46 +0100 Subject: [PATCH] refac: identify loader archives by content (#33460) * fix: apply the document archive size guard to every zip file, not just named extensions The decompression-bomb guard in the document loader only ran when the filename extension or the declared content type matched a fixed list, so an office archive renamed to a legacy or unknown extension (for example an .xlsx saved as .xls, .bin, or served from a URL with no extension) skipped the check entirely and was fully inflated in the worker. The guard now detects zip archives by content and checks every one of them, while non-archive files keep the previous behavior. * refac: identify loader archives by content The document loader now recognises archives by their content when checking their size. --- backend/open_webui/retrieval/loaders/main.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/backend/open_webui/retrieval/loaders/main.py b/backend/open_webui/retrieval/loaders/main.py index 971b124a9e..6e1f9fc047 100644 --- a/backend/open_webui/retrieval/loaders/main.py +++ b/backend/open_webui/retrieval/loaders/main.py @@ -94,15 +94,6 @@ known_source_ext = [ 'svg', ] -known_archive_ext = {'docx', 'epub', 'odt', 'pptx', 'xlsx'} -known_archive_content_types = { - 'application/epub+zip', - 'application/vnd.oasis.opendocument.text', - 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', -} - class ExcelLoader: """Fallback Excel loader using pandas when unstructured is not installed.""" @@ -538,7 +529,7 @@ class Loader: def _get_loader(self, filename: str, file_content_type: str, file_path: str): file_ext = filename.split('.')[-1].lower() - if file_ext in known_archive_ext or file_content_type in known_archive_content_types: + if zipfile.is_zipfile(file_path): max_file_size = self.config['rag.file.max_size'] try: max_file_size_bytes = int(max_file_size) * 1024 * 1024 if max_file_size else 100 * 1024 * 1024