ddn.data.xml.internal.io
Internal: shared resource loading policy and helpers.
This module centralizes external resource loading (external DTD subsets/entities, XInclude, schema includes/imports, catalogs, etc.) behind a single, security-oriented policy.
It is intentionally internal and may change without notice.
Types 2
structXmlResourcePolicy
Policy controlling which resources may be loaded.
Fields
bool allowFileIf `true`, allow reading from the local filesystem.bool allowNetworkIf `true`, allow URI-based loading (e.g. `http(s)://...`).size_t maxBytesMaximum number of bytes allowed when reading a resource (0 = unlimited).structXmlResourceLoader
A pluggable resource loader.
This loader is used to centralize resource loading (file/URI/callback) and optionally cache loaded resources by their resolved identifier.
Notes:
- This type is internal and may change without notice.
policy.maxBytesis enforced for both file and callback loads.
Fields
XmlResourcePolicy policyLoading policy.bool enableCacheIf `true`, cache loaded byte payloads by resolved identifier.const(ubyte)[] delegate(string uri, XmlResourcePolicy policy, XmlLocation loc) @safe fetchOptional callback used to load non-file URIs when `policy.allowNetwork=true`.private ubyte[][string] _cacheMethods
const(ubyte)[] loadBytes(
string resolved,
XmlErrorCode forbiddenCode,
XmlErrorCode ioErrorCode,
string purpose,
XmlLocation loc = XmlLocation.init) @safeFunctions 6
fn
string resolveReference(string base, string href) @safeResolves a reference `href` against a `base` identifier.fn
string loadTextResource(
string resolved,
XmlResourcePolicy policy,
XmlErrorCode forbiddenCode,
XmlErrorCode ioErrorCode,
string purpose,
XmlLocation loc = XmlLocation.init) @safeLoads a resource as text under `policy`.fn
string loadTextResource(
string resolved,
ref XmlResourceLoader loader,
XmlErrorCode forbiddenCode,
XmlErrorCode ioErrorCode,
string purpose,
XmlLocation loc = XmlLocation.init) @safeLoads a resource as text using a pluggable `loader`.fn
const(ubyte)[] loadBinaryResource(
string resolved,
XmlResourcePolicy policy,
XmlErrorCode forbiddenCode,
XmlErrorCode ioErrorCode,
string purpose,
XmlLocation loc = XmlLocation.init) @safeLoads a resource as raw bytes under `policy`.fn
const(ubyte)[] loadBinaryResource(
string resolved,
ref XmlResourceLoader loader,
XmlErrorCode forbiddenCode,
XmlErrorCode ioErrorCode,
string purpose,
XmlLocation loc = XmlLocation.init) @safeLoads a resource as raw bytes using a pluggable `loader`.private fn
const(ubyte)[] loadBinaryResource(
string resolved,
XmlResourcePolicy policy,
XmlErrorCode forbiddenCode,
XmlErrorCode ioErrorCode,
string purpose,
XmlLocation loc,
const(ubyte)[] delegate(string uri, XmlResourcePolicy policy, XmlLocation loc) @safe fetch) @safe