Skip to content

fix(fetcher): decode bad charset#1214

Merged
andrinoff merged 1 commit intofloatpane:masterfrom
guyua9:fix/decode-malformed-content-type
May 2, 2026
Merged

fix(fetcher): decode bad charset#1214
andrinoff merged 1 commit intofloatpane:masterfrom
guyua9:fix/decode-malformed-content-type

Conversation

@guyua9
Copy link
Copy Markdown
Contributor

@guyua9 guyua9 commented May 2, 2026

What?

  • Fix decodePart so malformed Content-Type headers still go through the charset decoder instead of returning raw bytes.
  • Add a best-effort charset fallback for invalid media parameters.
  • Add regression tests for malformed Content-Type with ISO-8859-1 bytes and malformed Content-Type without a charset.

Fixes #1085.

Why?

Malformed Content-Type headers can still include a usable charset. Returning raw bytes in that path makes non-UTF-8 email bodies render as mojibake. Decoding with the best-effort charset keeps those messages readable while preserving UTF-8 fallback behavior.

Tests

  • /Users/ming/.cache/go-toolchains/go1.26.2/bin/go test ./fetcher
  • /Users/ming/.cache/go-toolchains/go1.26.2/bin/go vet ./fetcher
  • /Users/ming/.cache/go-toolchains/go1.26.2/bin/go test ./fetcher ./config ./backend ./backend/jmap ./cli ./daemon ./daemonclient ./daemonrpc ./internal/httpclient ./plugin

Note: go test ./... was attempted locally, but this environment could not complete unrelated packages because of a proxy.golang.org EOF while downloading github.com/arran4/golang-ical and a local macOS CommandLineTools cgo architecture error.

@guyua9 guyua9 requested a review from a team as a code owner May 2, 2026 09:39
@github-actions github-actions Bot added the bug Something isn't working label May 2, 2026
Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

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

Hi @guyua9! Please fix the following issues with your PR:

  • Title: Is too long (54 characters). The PR title must be strictly under 40 characters.
  • Body: Missing the ## What? or ## Why? headings required by the PR template.

@guyua9 guyua9 changed the title fix(fetcher): decode charset on malformed content type fix(fetcher): decode bad charset May 2, 2026
@floatpanebot floatpanebot dismissed their stale review May 2, 2026 09:42

Formatting issues have been resolved. Thank you!

Copy link
Copy Markdown
Member

@andrinoff andrinoff left a comment

Choose a reason for hiding this comment

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

lgtm

@andrinoff
Copy link
Copy Markdown
Member

/approve

Copy link
Copy Markdown
Member

@floatpanebot floatpanebot left a comment

Choose a reason for hiding this comment

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

Approved on behalf of @andrinoff via /approve command.

@andrinoff andrinoff merged commit 459875f into floatpane:master May 2, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: decodePart drops charset transform when Content-Type parse fails

3 participants