Repository navigation
fix: separate Base64 text encoding from payload charset - #18
Open
Hanabi9248 wants to merge 1 commit into
Open
Hanabi9248 wants to merge 1 commit into
Hanabi9248 wants to merge 1 commit into
Conversation
Use ASCII for the Base64 carrier in basic and URL-safe string codecs. Keep the requested charset for original and recovered payload bytes. Add UTF-16 interoperability and round-trip regressions with UTF-8 and Latin-1 controls against the complete production class. Signed-off-by: Hanabi <317387557+Hanabi9248@users.noreply.github.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.
The explicit charset in the string codecs is currently used for both the payload and the Base64 carrier text. With UTF-16 this turns encoded ASCII bytes into unrelated characters and introduces BOM/zero bytes when decoding canonical Base64 input; even an encode/decode round trip can fail.
Use US_ASCII for the Base64 text in the basic and URL-safe string codecs. Keep the caller-selected charset for original payload bytes and recovered text. For example, UTF-16 encoding of
Amust produce/v8AQQ==(basic) or_v8AQQ==(URL-safe), preserving the payload BOM. JsonBuilder and other helpers are unchanged.Validation: compiled the complete production Base64Util plus six unchanged support classes against the real, already-installed Spring Core 5.2.10.RELEASE JAR, using JDK 25.0.4.101 with
javac --release 8. The standalone regression uses JDK java.util.Base64 as an independent oracle. Baseline: 8 failures and 4 passing controls; candidate: all 12 cases pass. Both alphabets cover UTF-16 encoding, canonical decoding and round trips, UTF-16LE encoding, default UTF-8 Chinese text and explicit Latin-1 controls. Three obsolete Java 8 source/target warnings were emitted.Example in Bash, from the repository root with SPRING_CORE_JAR pointing to an existing matching JAR:
Use a semicolon classpath separator on Windows. Java 8 runtime, Maven/Spring full-service tests, the whole repository and arbitrary charsets/invalid-input policies were not tested. This validates the public codec overloads, without claiming a specific application endpoint.
Assisted-by: OpenAI gpt-6.1-sol