Repository navigation
Decode base64Binary strictly in value holders and the rich parser - #131
Merged
Merged
Conversation
Add Base64Bin.decode, which ignores XML whitespace and otherwise requires the base64 alphabet in groups of four with padding only at the end. JavaBase64Holder.lex and the XMLStreamReaderExtImpl base64 getters now use it instead of the JDK MIME decoder, which drops non-alphabet chars and accepts unpadded input. Follow-up to apache#123: the rich parser getters still accepted stray chars, and unpadded or wrongly sized values (e.g. "SGVsbG8") still validated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #123.
#123 rejected non-alphabet characters in
JavaBase64Holder.lex, but two gaps remained:XMLStreamReaderExtImpl.getBase64Value/getAttributeBase64Value(both overloads) still decoded withBase64.getMimeDecoder(), soSGVsbG8=!!!!came back asHello.SGVsbG8andSGVsbGstill validated, although the base64Binary lexical space requires 4-char groups with=padding only at the end.This adds
org.apache.xmlbeans.impl.util.Base64Bin.decode(a sibling ofHexBin; it returns null for invalid input). It strips XML whitespace, requires length % 4 == 0, then uses the basicBase64decoder, which rejects non-alphabet chars and misplaced padding. The holder and all three rich parser getters use it.Not enforced: XSD 1.0's restriction on the final char before padding (non-zero trailing bits, e.g.
SGW=). The JDK accepts these, and rejecting them looked more likely to break real documents than to catch anything.Tests: new
Base64BinTest;Base64BinaryValidateTestgains padding/length cases and compiles the schema once;RichParserTestscovers the stray-char and unpadded cases on element and attribute getters.🤖 Generated with Claude Code