Skip to content

Escape colon in XML names written by escaping XmlNameProcessors - #921

Open
Sahana2524 wants to merge 1 commit into
FasterXML:3.xfrom
Sahana2524:xml-name-colon-escape
Open

Sahana2524 wants to merge 1 commit into
FasterXML:3.xfrom
Sahana2524:xml-name-colon-escape

Conversation

@Sahana2524

Copy link
Copy Markdown
Contributor

Colon passes through the escaping name processors

Base64NameProcessor counts a name holding a colon as already valid, and ReplaceNameProcessor keeps the colon in its allowed set, so a content-derived name such as a Map key "a:b" is written out verbatim. Output is namespace-aware, so that colon comes back as a prefix nothing declares and the document no longer reads: <DTO><badMap><a:b>v</a:b></badMap></DTO> fails with Undeclared namespace prefix "a", while "a:b:c" and ":leading" do not even parse. That round trip is what these two processors are there to protect, and newAlwaysOnBase64Processor() already handles the same keys cleanly, so the colon looks like an oversight in the allowed sets rather than a deliberate exception.

Dropping it means such names get escaped (base64, still a lossless round trip) or replaced instead. Only encodeName changes: decodeName keys off the prefix for base64 and is a no-op for replacement, so names coming from a non-namespace-aware parser are still passed through untouched. Covered by round-trip tests in XmlNameEscapeTest; the rest of the suite is unchanged.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

🧪 Code Coverage Report

Metric Coverage Change
Instructions coverage 77.69% 📈 +0.000%
Branches branches 70.97% 📈 +0.000%

Coverage data generated from JaCoCo test results

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant