Expand description
Pluggable resolver for external XML resources (DTDs, parsed entities) referenced by SYSTEM / PUBLIC identifier.
§Why this exists
XML 1.0 lets DOCTYPE declarations and <!ENTITY> declarations
reference external resources by URL. Loading those resources
is the primary XXE attack vector — a malicious document can
cause a parser to fetch arbitrary URLs, leak local files, or
trigger SSRF against internal services.
SupXML’s default behaviour is to refuse all external loading.
Callers who genuinely need it (DocBook publishing, XHTML 1.0
processing, JATS, etc.) opt in by setting
ParseOptions::external_resolver to either:
- The recommended
FilesystemResolver— loads from a configured allowlist of local directories, optionally consulting an OASIS catalog first. - A
NetworkResolver(behind thenetwork-resolverfeature) — fetches over HTTPS from a configured host allowlist with SSRF defenses. - A
ChainedResolvercomposing the two — try local first, fall back to network for anything not pre-cached. - A custom
EntityResolverimpl for bespoke setups (in-memory bundles, S3, audit-logging, etc.).
The presence of a resolver IS the opt-in. Without one, every external reference is rejected.
Structs§
- Chained
Resolver - Composes multiple resolvers, trying each in order. The first
resolver to return either
Okor a non-Refusederror wins;Refusedfalls through to the next resolver. - Filesystem
Resolver - Recommended default resolver: loads from filesystem only, refuses anything outside the configured allowed-root directories, optionally consults an OASIS catalog first.
- InMemory
Resolver - Resolver backed by an in-memory map from system_id to bytes. Refuses anything not in the map. Useful in tests where you want deterministic resolution without filesystem dependencies.
- Network
Resolver - HTTPS-fetching resolver. Hardened by default with multiple SSRF and amplification defenses; the constructor requires a host allowlist so there’s no convenient “any host” mode.
Enums§
- Resolve
Error - Why a resolver couldn’t deliver the requested bytes.
Traits§
- Entity
Resolver - Resolves external XML resources by their public/system identifier. Implementors decide what URLs are loadable, where the bytes come from, and what security checks apply.