Document Inputs
The PDF bundle declares input support for HTML, CSS, and SVG under pdf/lib. The inspected evidence establishes parser-local call edges and data handoffs, but no outer PDF caller, registration lifecycle, or successful end-to-end execution record. The copies under public/pdf are bundled duplicates, not separate product capabilities.
[!WARNING] Verify the outer PDF integration before treating these libraries as active. HTML input assumes UTF-8 and requires
iconv; without it,HTML5_InputStreamthrowsNot implemented, please install iconv. SVG stores a caller-supplied filename and passes it directly tofopenwithout a proven validation, allowlist, ownership, or isolation boundary. SVG text callsfillText, while the inspectedSvg\Surface\CPdfimplementation exposesaddText; no matchingfillTextimplementation or bridge was retrieved.
Declared input relationships
flowchart TD
h["HTML5_Parser::parse / parseFragment"] --> t["HTML5_Tokenizer"]
t --> b["HTML5_TreeBuilder"]
b --> r["saved HTML result"]
c["Sabberworm\CSS\Parser"] --> d["Sabberworm\CSS\CSSList\Document"]
d -. "registration not proven" .-> s["Svg\Style::fromStyleSheets"]
f["Svg\Document::loadFile"] --> x["Svg\Document XML callbacks"]
x --> q["Svg\Tag\Text"]
q --> ft["surface fillText"]
cp["Svg\Surface\CPdf::addText"]
pdf/lib/html5lib/Parser.php exposes two source-defined entry points:
- HTML5_Parser::parse creates an
HTML5_Tokenizerwith the supplied text and optional builder, callsparse(), and returnssave(). - HTML5_Parser::parseFragment creates the tokenizer, configures the supplied context through the tokenizer's fragment path, parses the fragment, and returns
save().
HTML5_Tokenizer constructs an HTML5_InputStream from the supplied data. When no custom builder is provided, it uses an HTML5_TreeBuilder and initializes the content model to PCDATA. Its parse() method runs the tokenizer state machine from the data state while consuming input and producing HTML tokens or parse-error tokens.
HTML5_Tokenizer::emitToken first emits queued input-stream errors, checks duplicate start-tag attributes and invalid end-tag attributes, and forwards non-dry tokens to the configured tree builder. HTML5_Tokenizer::save returns the tree builder's saved result.
pdf/lib/html5lib/InputStream.php normalizes the input before tokenization. It assumes UTF-8, removes one leading UTF-8 BOM, converts NULL bytes and carriage-return sequences to their normalized representations, and records NULL or invalid-codepoint conditions as tokenizer parse errors. Its conversion path uses iconv with invalid input ignored; the constructor raises Not implemented, please install iconv when iconv is unavailable.
pdf/lib/php-css-parser/lib/Sabberworm/CSS/Parser.php constructs a ParserState from stylesheet text, parser settings, and a starting line number. If settings are omitted, it creates default settings. Sabberworm\CSS\Parser::parse passes that state to Sabberworm\CSS\CSSList\Document::parse, which builds a CSS Document.
The CSS document exposes getAllDeclarationBlocks(). Its recursive collection walks nested CSSBlockList contents and returns each DeclarationBlock.
pdf/lib/php-svg-lib/src/Svg/Style.php has two local style-input paths:
- Svg\Style::fromAttributes applies recognized presentation attributes first. If an inline
styleattribute exists, it parses that declaration text and applies those declarations afterward. - Svg\Style::fromStyleSheets reads stylesheet-like objects from the SVG document, iterates their declaration blocks and selectors, matches class selectors or exact tag names, and applies matching rules through the supported style map.
The inspected scope does not prove that a parsed Sabberworm Document is registered with the SVG document through appendStyleSheet before fromStyleSheets performs resolution.
Svg\Document::loadFile stores the supplied filename; it does not itself read or parse the file. Both Svg\Document::getDimensions and Svg\Document::render later pass that stored filename directly to fopen.
Svg\Document::getDimensions creates a UTF-8 XML parser and reads the file in 8192-byte chunks until the first svg element is found. It derives dimensions from the root width, height, and four-part viewBox attributes, using the SVG size-conversion logic in pdf/lib/php-svg-lib/src/Svg/Style.php.
Svg\Document::render assigns the target surface, initializes XML element and character-data callbacks, optionally translates by the viewBox origin, reads the stored file in 8192-byte chunks, finalizes XML parsing, and frees the parser. The start-element callback maps recognized names to tag objects—including StyleTag and Text—stores identified definitions, pushes tags onto the stack, and passes attributes to the tag handler. The character-data callback forwards data to appendText only when the current stack item is a Text or StyleTag.
For text, pdf/lib/php-svg-lib/src/Svg/Tag/Text.php accumulates character data through Svg\Tag\Text::appendText. At Svg\Tag\Text::end, the source selects the current font, adjusts the x-coordinate for middle or end text anchors using measured text width, trims the accumulated text, and calls fillText on the surface. The inspected pdf/lib/php-svg-lib/src/Svg/Surface/CPdf.php instead declares addText; the cross-library text sink therefore remains unresolved.