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

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).

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.maxBytes is 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] _cache
Methods
const(ubyte)[] loadBytes( string resolved, XmlErrorCode forbiddenCode, XmlErrorCode ioErrorCode, string purpose, XmlLocation loc = XmlLocation.init) @safe

Functions 6

fnstring resolveReference(string base, string href) @safeResolves a reference `href` against a `base` identifier.
fnstring loadTextResource( string resolved, XmlResourcePolicy policy, XmlErrorCode forbiddenCode, XmlErrorCode ioErrorCode, string purpose, XmlLocation loc = XmlLocation.init) @safeLoads a resource as text under `policy`.
fnstring 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`.
fnconst(ubyte)[] loadBinaryResource( string resolved, XmlResourcePolicy policy, XmlErrorCode forbiddenCode, XmlErrorCode ioErrorCode, string purpose, XmlLocation loc = XmlLocation.init) @safeLoads a resource as raw bytes under `policy`.
fnconst(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 fnconst(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