base64: Unexpected result when decoding data with garbage
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 24.1k
- Forks
- 2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 365
Description
Hi,
I have run in to a problem when trying to base64 decode a file that contains garbage data. This is with the coreutils version 0.8.0, installed from the Ubuntu 26.04 Resolute apt repository.
Consider the following truncated content from my_base64_file.txt:
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJjMjQ5MmF
Yes! It contains a ., which is garbage. I know.
When decoding it with base64 (GNU coreutils) 9.4 the result is:
base64 -d my_base64_file.txt --> {"alg":"RS256","typ":"JWT"}base64: invalid input
base64 -di my_base64_file.txt --> {"alg":"RS256","typ":"JWT"}{"jti":"c2492abase64: invalid input
But, with base64 (core uutils 0.8.0) I get:
base64 -d my_base64_file.txt --> base64: error: invalid input
base64 -di my_base64_file.txt --> base64: error: invalid input
Is there something I am missing here, or is there a bug with the --ignore-garbage feature?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the documented base64 -d and base64 -di commands with the provided input, then trace the base64 command's --ignore-garbage handling. Done means the behavior matches the reported GNU coreutils results, including decoded output and the invalid-input diagnostic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 64/100