Skip to content

Reject invalid base64 characters#426

Closed
CodingFeng101 wants to merge 1 commit into
pallets:mainfrom
CodingFeng101:codex/reject-invalid-base64
Closed

Reject invalid base64 characters#426
CodingFeng101 wants to merge 1 commit into
pallets:mainfrom
CodingFeng101:codex/reject-invalid-base64

Conversation

@CodingFeng101

Copy link
Copy Markdown

What changed

base64_decode() now rejects non-ASCII input and characters outside the URL-safe base64 alphabet before adding padding and decoding.

Why

The previous path encoded text with errors="ignore", so non-ASCII characters were silently dropped before decoding. Python's base64 decoder is also permissive about some non-alphabet characters. For signed payloads, malformed base64 input should be rejected rather than normalized by dropping characters.

Validation

  • PYTHONPATH=src python -m pytest tests\test_itsdangerous\test_encoding.py -q
  • PYTHONPATH=src python -m pytest -q
  • python -m ruff check src\itsdangerous\encoding.py tests\test_itsdangerous\test_encoding.py
  • python -m ruff format --check src\itsdangerous\encoding.py tests\test_itsdangerous\test_encoding.py
  • git diff --check

@davidism davidism closed this Jun 30, 2026
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