Skip to content

Fix Base64 padding separated by whitespace - #1491

Merged
SGSSGene merged 1 commit into
jbeder:masterfrom
alex-thiessen-for-siemens:fix/base64-padding-whitespace-pr
Sep 8, 2026
Merged

Fix Base64 padding separated by whitespace#1491
SGSSGene merged 1 commit into
jbeder:masterfrom
alex-thiessen-for-siemens:fix/base64-padding-whitespace-pr

Conversation

@alex-thiessen-for-siemens

Copy link
Copy Markdown
Contributor

Summary

Fix Base64 decoding when whitespace separates padding characters.

DecodeBase64("TQ= =") previously emitted an extra zero byte because it
checked the raw preceding input character after whitespace had been skipped.
The decoder now tracks whether the previous non-whitespace Base64 character
was padding. The focused test verifies that the result remains the single byte
M.

Validation

  • C++11 CMake/CTest: 3/3 tests passed.
  • Pinned Debian Trixie evaluation: CMake/CTest, ASan/UBSan, Valgrind,
    clang-format, clang-tidy, exhaustive cppcheck, Bazel, and Bzlmod passed.
  • PyYAML 6.0.3, using YAML 1.1 !!binary native-value semantics, matched
    the decoded byte 4d.
  • libyaml 0.2.5 matched the yaml-cpp parser/event stream for the fixture.

Track the previous non-whitespace Base64 character when deciding whether
padding terminates a decoded byte. This preserves YAML 1.1 !!binary
decoding when whitespace appears between padding characters.

Cover whitespace-separated padding with a focused test that preserves
the single-byte result for the canonical padded form.

Reference verification:
- PyYAML 6.0.3 (YAML 1.1 !!binary, native value): matched 4d.
- libyaml 0.2.5 (parser/event layer): matched the yaml-cpp event stream.

@SGSSGene SGSSGene left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! thank you!

@SGSSGene
SGSSGene merged commit 8eb618e into jbeder:master Sep 8, 2026
46 checks passed
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.

2 participants