mirror of
https://github.com/docling-project/docling-core.git
synced 2026-11-18 20:27:00 +00:00
- 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>
17 lines
517 B
Python
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()
|