Repository navigation
Open
Labels
bugSomething isn't workingcodegenPolyXML polyglot code generationtarget:cppC++ code generator targettarget:javaJava code generator targettarget:rustRust code generator targettarget:typescriptTypeScript code generator target
Description
Summary
Audit of recent nillable, scalar-parsing, and XML parser hardening PRs identified three related codec correctness gaps in generated code:
- Rust
xsi:nilmissing onnillable="true"nested fields (crates/polyxml-core/src/codegen/rust/mod.rs): Whiledecode_xml/encode_xmlfor simple/flat fields checksOption, Rust streaming codecs do not checkxsi:nil="true"/"1"onnillable="true"child elements before delegating to nestedT::decode_xml/T::decode_xml_empty. IfAttrOnlyhas a required attributeid,<item xsi:nil="true"/>fails withMissing required attribute 'id'. Conversely,encode_xmlomitsminOccurs="1" nillable="true"elements whenNoneinstead of writing<item xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>(unlike C++20 and Javadirect-codec). - Permissive
xs:decimalexponent notation (eclipse-ee4j/jaxb-ri#2053): Per W3C XSD Part 2 §3.2.3.1, the lexical space ofxs:decimalis[+-]?[0-9]+(\.[0-9]+)?(and.123/123.), and MUST NOT contain exponent notation (1e5,1.5E-2). Currently Javadirect-codec(new java.math.BigDecimal(raw)), Rust/Gof64, C++20parse_float<double>, and TypeScriptparseFloatValueall accept1e5as a validxs:decimal. - Self-contained C++20 & TypeScript
direct-codecXML well-formedness (NaturalIntelligence/fast-xml-parser#909,#913,#915,#916,tafia/quick-xml#1044): Our zero-dependency recursive-descent parsers incrates/polyxml-core/src/codegen/cpp/codec.rsandcrates/polyxml-core/src/codegen/typescript/codec.rscurrently allow:--inside XML comments (<!-- a -- b -->)- raw
]]>in element character data - duplicate attributes on the same start tag (silently overwriting in TS)
- raw
<or unknown/unterminated&entities inside attribute values or character data - arbitrary trailing non-whitespace/non-misc garbage after the closing root tag (
<Root/>trailing_junk) becauseparse_xml_documentreturns immediately after parsing the root element without trailingskip_misc+ EOF verification.
Upstream references: tefra/xsdata#1233 (tefra/xsdata#1233), tefra/xsdata#1234 (tefra/xsdata#1234), tefra/xsdata#1244 (tefra/xsdata#1244), eclipse-ee4j/jaxb-ri#2053 (eclipse-ee4j/jaxb-ri#2053), NaturalIntelligence/fast-xml-parser#909 (NaturalIntelligence/fast-xml-parser#909), NaturalIntelligence/fast-xml-parser#913 (NaturalIntelligence/fast-xml-parser#913), NaturalIntelligence/fast-xml-parser#915 (NaturalIntelligence/fast-xml-parser#915), NaturalIntelligence/fast-xml-parser#916 (NaturalIntelligence/fast-xml-parser#916), and tafia/quick-xml#1044 (tafia/quick-xml#1044).
Minimal Reproducers
- Nillable attributes-only complexType:
tests/fixtures/conformance/wave9/nil_attr_only.xsd - Strict
xs:decimallexical space:tests/fixtures/conformance/wave9/decimal_strict.xsd
Expected Behavior
- Rust streaming codecs inspect
xsi:nil("true"/"1") onnillable="true"child elements (mapping toNoneand skipping child element events) and emitxsi:nil="true"whenminOccurs >= 1 && nillable && value.is_none(). xs:decimalparsers in generated codecs rejecte/Eexponent notation per W3C XSD Part 2 §3.2.3.1.- C++20 and TypeScript
parse_xml_document/parseXmlDocumentenforce trailing misc-only EOF checks, reject--inside comments, reject raw]]>in text, reject duplicate attribute names, and reject unescaped<or unknown/unterminated&...in text/attributes.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingcodegenPolyXML polyglot code generationtarget:cppC++ code generator targettarget:javaJava code generator targettarget:rustRust code generator targettarget:typescriptTypeScript code generator target
Activity