feat(xml): read the internal subset and expand declared entities #554
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/552-xml-internal-subset"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #552
Refs #78 (step 2 of the XML epic)
What
std/xmlreads the internal subset of a document type declaration and expands the entities it declares.NDATAentities are recorded and an error where they are referenced (WFC: No External Entity References, WFC: Parsed Entity). Nothing is fetched or opened; an external subset is not read.Xml.entityLimit: Int = 1000000: the replacement-text length of every reference counts, and the error names the option (like yamlaliasLimit). Cuts off a billion laughs and a quadratic blowup before memory is touched.xmlnstakes part in resolution. Values of a type other thanCDATAare normalised per XML 1.0 3.3.3. ELEMENT/NOTATION/comment/PI declarations are checked and skipped.Doctypenode keeps only name and identifiers;Xml.writewrites it without a subset;parse(write(tree)) == treeis tested with subsets.Decisions to review
entityLimit(stricter than the specification asks, deliberate hardening).Tests
std/xml/tests/xml.test.trb: billion laughs, quadratic blowup, XXE shape, self and mutual recursion, limits, defaults, namespaces, round trip with a subset.std/xml/tests/conformance-cases.trb: cases named by production/constraint (the old "refused" entries are replaced);NOTICE.mdupdated.torb test std/xml(470 passed),torb format --check std/xml,torb docs check/source/declarations/index/skill --check,tools/check-commits.sh origin/main HEAD. Bootstrap and gates are left to CI.Docs
docs/standard-library/xml.md,index.md, doc comments,docs/design/ENCODING.mdsection 16 point 16 and the slice 8 row,skills/regenerated.9b8945e2c09bf16642dbstd/xmlreads the internal subset: entities, default attributes and an expansion limit (step 2 of #78) #552Approved at
9bf1664.std/xml/tests/xml.test.trb: billion laughs, quadratic blowup, XXE shape, self and mutual recursion, limits, defaults, namespaces, round trip. Conformance cases are named by production or constraint. CI is green on this head: tier A, bootstrap, gates, pdisc, commit messages.entityLimitbounds expansion. Recursion is caught viaopen, and nesting is capped bymaxDepth. Replacement text is parsed by its own parser and must be well-balanced. Predefined-entity redeclaration and the&idiom behave per the Recommendation.Doctypekeeps name and identifiers, andwriteomits the subset.xml.md,index.md, ENCODING.md §16 point 16 and the slice 8 row, NOTICE.md and the regeneratedskills/are updated.Non-blocking:
entityLimiton every element that uses it. A large trusted document with many defaulted elements can hit the 1000000 default. That is deliberate and documented, and the option can be raised, but you may want the error message to mention defaults when they are what tipped the limit.