Skip to content

Base64 decode error points at the wrong character when the input has spaces or line breaks #310

Closed

Description

@anurag629

Decode SGVs bG8! in the Base64 tool. The error says the illegal character "!" is at position 7, but in what you typed it's the 9th character. base64ToBytes (lib/base64-utils.ts, line 38) strips all whitespace first (line 41) and reports the index in the stripped string, counted from 0 (lines 48 to 53). With pasted multi-line Base64 the number is even further off.

What to do

  • Report where the character is in the original input, counted from 1. For input with line breaks, line and column is even clearer.

Where to look

  • lib/base64-utils.ts: base64ToBytes (lines 38 to 60)
  • lib/__tests__/base64-utils.test.ts

Acceptance criteria

  • SGVs bG8! reports position 9
  • An illegal character on the second line of multi-line input is reported where it really is
  • Tests that fail on the current code
  • npm run lint, npm run test and npm run build pass

Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off develop, and open your PR against develop with Closes #310 in the description.

Activity

  1. Aaqibhafeezkhan commented on Oct 23, 2026

    @Aaqibhafeezkhan
    Contributor

    I'd like to work on this issue. I'll correct the Base64 decoder's error-position reporting so it refers to the original input, including whitespace and line breaks, and add regression tests for the reported case and related malformed inputs.

  2. anurag629 commented on Oct 23, 2026

    @anurag629
    MemberAuthor

    Hey @Aaqibhafeezkhan, go for it! It's yours.

  3. added a commit that references this issue on Oct 24, 2026
    24ed2a0
  4. added a commit that references this issue on Oct 27, 2026
    7dd0ee1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workinggood first issueGood for newcomershacktoberfestGood pick for Hacktoberfest contributors

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions