Repository navigation
feat(xmlsec1)!: own document tree for the libxmlsec1 surface, no libxml2 - #454
Conversation
The libxmlsec1-compatible library and the tree library link, load and call no C library besides the platform's C runtime. Documents are the core's trees behind opaque handles, read and changed through our own tree functions shaped like libxml2's. - core: OwnedTree (feature owned-tree, which compiles the xmloxide arena for the tree without making xmloxide a parser backend), a Rust-owned mutable document parsed from text or from bytes in the encoding they select, under the policy with its limits enforced while parsing and a DOCTYPE the policy forbids refused before its subset is read; it implements the external-tree contract; XmlDocument lends it to an operation (from_owned_tree, into_owned_tree) or reads a read-only snapshot of it (snapshot_of_external_tree); its ID table ties each ID to the attribute carrying it, holds normalized xml:id values and the IDs a caller registers, keeps them unique among live elements and follows attribute edits - xml-sec-libxml2: the handle table (documents, nodes, attributes, namespace declarations and XPath namespace nodes, node sets) with handles and document slots from a counter that never repeats, validated on every use, and a lock per document; the xs* tree functions and xs_tree.h with incomplete types; output and input buffers over the caller's callbacks or memory; the heap released with xsFree; a per-thread generic error channel; xs_tree_document, a clean C API document over a tree document that reads the tree at every operation - xml-sec-xmlsec1: every tree access goes through the handles; node sets, buffers and parsing are the library's own; read-only transforms read a snapshot so C callbacks still see the live tree; the headers are libxmlsec1's with xs_tree.h in place of libxml2's, generated and checked by xmlsec1-headers, and leave out the functions that read a file or install an entity loader - the C test programs use the tree functions; capi --xmlsec1 builds each against the libxmlsec1 oracle with the tree calls mapped onto libxml2 and against the library, and both print the same; the library's own round trips link nothing else, on every platform BREAKING CHANGE: xs_libxml2_document is replaced by xs_tree_document over a tree document of xs_tree.h; xmlSecParseFile, xmlSecBufferReadFile, xmlSecParsePrepareCtxt and xmlSecSetExternalEntityLoader are not offered. Part of #451
|
Important Review skippedToo many files! This PR contains 104 files, which is 4 over the limit of 100. To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Summary
xml-sec-xmlsec1) and the tree library (xml-sec-libxml2) link, load and call no C library besides the platform's C runtime: a program uses libxmlsec1's interfaces without libxml2.xsprefix where libxml2 hasxml).Changes
OwnedTree(featureowned-tree, which leaves the parser backend a build selects alone), a Rust-owned mutable document over the xmloxide arena, parsed from text or from bytes in the encoding they select, under the policy with its limits enforced while parsing, implementing the external-tree contract;XmlDocument::from_owned_tree/into_owned_treelend it to an operation andsnapshot_of_external_treereads it without taking it, as a read-only document; the tree's ID table ties each ID to the attribute carrying it (xml:idand caller-registered IDs), keeps IDs unique among live elements and follows attribute edits.xml-sec-libxml2: the handle table (documents, nodes, attributes, namespace declarations, XPath namespace nodes, node sets) with values from a counter that never repeats and a lock per document; thexs*tree functions andinclude/xs_tree.hwith incompletexmlDoc/xmlNode/xmlNs/xmlAttr/xmlNodeSettypes; output and input buffers over the caller's callbacks or memory; the heap released withxsFree;xsSetGenericErrorFunc;xs_tree_document, a clean C API document over a tree document that reads and edits the tree at every operation, so the caller may change it between calls.xml-sec-xmlsec1: every tree access goes through those handles; node sets, buffers and parsing are the library's own; read-only transforms (C14N, the XPath family, the relationship transform) read a snapshot, so C callbacks still see the live tree; error reports go through the generic error channel.xs_tree.hin place of libxml2's headers and the functions that read a file or install an entity loader left out (xmlSecParseFile,xmlSecBufferReadFile,xmlSecParsePrepareCtxt,xmlSecSetExternalEntityLoader);xmlsec1-headerswrites and checks them against the oracle.Testing
The C test programs use the tree functions:
capi --xmlsec1builds each once against the libxmlsec1 1.3.13 oracle, with its tree calls mapped onto libxml2, and once against the library, and both print the same;capiruns the clean C API and tree-document round trips linking nothing else, on Linux, macOS and Windows. Tests, lints, formatting, the header check and the feature contract pass.Replaces #453.
BREAKING CHANGE:
xs_libxml2_documentis replaced byxs_tree_documentover a tree document ofxs_tree.h;xmlSecParseFile,xmlSecBufferReadFile,xmlSecParsePrepareCtxtandxmlSecSetExternalEntityLoaderare not offered.Part of #451