Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::xml::XMLParser::Options Struct Reference

Options to modify the parsing behavior. More...

#include "donner/base/xml/XMLParser.h"

Public Member Functions

constexpr Options ()
 Default options.

Static Public Member Functions

static Options ParseAll ()
 Parse all nodes in the XML document, including comments, the doctype node, and processing instructions.

Public Attributes

size_t maximumInputSize = 16 * 1024 * 1024
 Maximum encoded XML input bytes accepted before parsing.
bool parseComments = false
 Parse comments in the XML document, e.g.
bool parseDoctype = true
 Parse the doctype node in the XML document, e.g.
bool parseCustomEntities = false
 Parse custom entities in the XML document, e.g.
bool parseProcessingInstructions = false
 Parse processing instructions in the XML document, e.g.
bool disableEntityTranslation = false
 Disable entity translation during parsing.
int maxEntityDepth = 64
 Maximum nesting depth allowed while expanding entities.
uint64_t maxEntitySubstitutions = 1'000
 Maximum total entity substitutions allowed for a single document parse.
uint64_t maxElements = kDefaultMaximumElements
 Maximum total number of elements (and other tree-nodes) allowed in a single document parse.
uint64_t maxAttributesPerElement = 1'000
 Maximum number of attributes permitted on a single element.
uint64_t maxTotalAttributes = kDefaultMaximumTotalAttributes
 Maximum attributes retained across the whole document.
uint64_t maxEntityDeclarations = 1'024
 Maximum entity declarations retained from a document type definition.
uint64_t maxEntityDeclarationBytes = 1024 * 1024
 Maximum aggregate entity-name and replacement bytes retained.
int maxNestingDepth = kDefaultMaximumNestingDepth
 Maximum element nesting depth in the parsed tree.

Static Public Attributes

static constexpr uint64_t kDefaultMaximumElements = 8'192
 Default tree-node envelope sized for downstream ECS/style allocation on desktop and Wasm.
static constexpr uint64_t kDefaultMaximumTotalAttributes = 100'000
 Default aggregate attribute envelope retained across one document.
static constexpr int kDefaultMaximumNestingDepth = 256
 Default maximum element nesting depth.

Detailed Description

Options to modify the parsing behavior.

Member Data Documentation

◆ disableEntityTranslation

bool donner::xml::XMLParser::Options::disableEntityTranslation = false

Disable entity translation during parsing.

If this flag is set to true, built-in entities such as & and < will not be translated to their respective characters.

◆ maxAttributesPerElement

uint64_t donner::xml::XMLParser::Options::maxAttributesPerElement = 1'000

Maximum number of attributes permitted on a single element.

Defaults to 1'000, which is far more than any realistic SVG needs. Refuses the "billion-attribute" expansion where an attacker piles thousands of attributes onto a single tag to amplify per-attribute callback / validation work.

◆ maxElements

uint64_t donner::xml::XMLParser::Options::maxElements = kDefaultMaximumElements

Maximum total number of elements (and other tree-nodes) allowed in a single document parse.

Defaults to 8'192, bounding downstream ECS and computed-style storage as well as the XML tree itself. Failing to stay under this limit causes parsing to fail with a resource exhaustion error.

◆ maxEntityDepth

int donner::xml::XMLParser::Options::maxEntityDepth = 64

Maximum nesting depth allowed while expanding entities.

Defaults to 64. Failing to stay under this limit will cause parsing to fail with a resource exhaustion error.

◆ maxEntitySubstitutions

uint64_t donner::xml::XMLParser::Options::maxEntitySubstitutions = 1'000

Maximum total entity substitutions allowed for a single document parse.

Defaults to 1'000. Failing to stay under this limit will cause parsing to fail with a resource exhaustion error.

◆ maxNestingDepth

int donner::xml::XMLParser::Options::maxNestingDepth = kDefaultMaximumNestingDepth

Maximum element nesting depth in the parsed tree.

Defaults to 256. This is the structural depth of <a><b><c>...</c></b></a>, orthogonal to maxEntityDepth. Exceeding it causes parsing to fail with a resource exhaustion error - this protects both the parser (which recurses into parseNodeContents) and later consumers (CSS cascade, renderers) from unbounded stacks.

◆ parseComments

bool donner::xml::XMLParser::Options::parseComments = false

Parse comments in the XML document, e.g.

<!-- ... -->. If this flag is set to true, comments will be parsed as donner::xml::XMLNode::Type::Comment nodes added to the document tree.

◆ parseCustomEntities

bool donner::xml::XMLParser::Options::parseCustomEntities = false

Parse custom entities in the XML document, e.g.

<!ENTITY ...>. If this flag is set to true, custom entities will be parsed and and translated in the document tree.

◆ parseDoctype

bool donner::xml::XMLParser::Options::parseDoctype = true

Parse the doctype node in the XML document, e.g.

<!DOCTYPE ...>. If this flag is set to true, the doctype node will be parsed as a donner::xml::XMLNode::Type::DocType node added to the document tree.

◆ parseProcessingInstructions

bool donner::xml::XMLParser::Options::parseProcessingInstructions = false

Parse processing instructions in the XML document, e.g.

<?php ...>. If this flag is set to true, processing instructions will be parsed as donner::xml::XMLNode::Type::ProcessingInstruction nodes added to the document tree.


The documentation for this struct was generated from the following file: