Files
docling-core/docling_core/utils/settings.py
Panos Vagenas aee0674a28 fix(doclang): add deserialize size, depth, and element budgets (#683)
- Cap DocLang XML input bytes before `parseString`
- Bound nesting depth and element count after DOM construction
- Expose limits via settings / `deserialize_str` kwargs and cover with unit tests

Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
2026-07-14 15:49:17 +02:00

17 lines
517 B
Python

from pydantic_settings import BaseSettings, SettingsConfigDict
class CoreSettings(BaseSettings):
model_config = SettingsConfigDict(env_prefix="DOCLINGCORE_")
allow_image_file_uri: bool = False
max_image_decoded_size: int = 20 * 1024 * 1024 # 20MB
# DocLang deserialize budgets (DoS protection for untrusted markup / .dclx)
max_doclang_xml_bytes: int = 128 * 1024 * 1024 # 128 MiB
max_doclang_xml_depth: int = 128
max_doclang_xml_elements: int = 1_000_000
settings = CoreSettings()