mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-15 09:31:21 +00:00
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.
This commit is contained in:
parent
96c1cfca6e
commit
4adf3083f3
1 changed files with 1 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue