isXmlNameStart's alternating &&/|| chain scored cognitive complexity 28.
Extracting inRange(cp, lo, hi) collapses it to a flat || sequence and
keeps the range list 1:1 with the XML 1.0 NameStartChar production.
isXmlNameChar updated the same way. No behaviour change.
Co-Authored-By: Claude <[email protected]>
XML.toString emitted JSONObject keys verbatim as tag names, so a key
containing '<', '>' or '/' broke out of its element and injected
arbitrary sibling structure into the output. Per #294/#123 the agreed
approach is to throw on invalid input rather than mangle it.
- Add mustBeXmlName / isXmlNameStart / isXmlNameChar implementing the
XML 1.0 (5th ed.) Name production, code-point aware.
- Validate tagName at method entry and each key at the top of the key
loop (skipping the cDataTagName sentinel).
- Rewrite XMLTest.shouldHandleIllegalJSONNodeNames and
XMLConfigurationTest.shouldHandleIllegalJSONNodeNames (previously
documenting the pass-through behaviour) to assert the throw.
- Add XMLTest.toStringRejectsElementInjectionInKey covering the #1071
payload and an invalid caller-supplied tagName.
- Add XMLTest.toStringAcceptsValidXmlNames covering hyphen/dot/
underscore/colon, Latin-1 letters, and the cDataTagName sentinel.
Fixes#1071. Also resolves the long-standing well-formedness question
in #166 / #294 / #308.
Co-Authored-By: Claude <[email protected]>
Provide both the type and value that failed conversion. Tries not to
"toString" large value types like Arrays or Maps. For those types it
will just output the type and not a value.
* updated tests to support BigDecimal as the backing type for numbers
* updated some test resource handling to java7 try-with-resources format
* cleaned up some other minor compiler warnings