Skip to content

Bug: gmail get corrupts URLs in email body (quoted-printable decoding issue) #159

@100menotu001

Description

@100menotu001

Description

When retrieving emails with gog gmail get, URLs containing = characters are corrupted. The = sign is replaced with the Unicode replacement character (U+FFFD).

Steps to Reproduce

  1. Receive an email containing a URL with query parameters (e.g., a magic link with ?token_hash=abc123&type=xyz)
  2. Run gog gmail get <message_id>
  3. Observe the URL in the output

Expected Behavior

URL should be intact:

https://example.com/auth?token_hash=abc123&type=magiclink

Actual Behavior

URL is corrupted:

https://example.com/auth?token_hash�abc123&type�magiclink

The = characters are replaced with (U+FFFD).

Root Cause

The issue appears to be in the quoted-printable decoding. Emails using Content-Transfer-Encoding: quoted-printable encode = as =3D. When decoding, gog seems to mishandle this.

Workaround

Using --format=raw --json and manually decoding works correctly:

gog gmail get <id> --format=raw --json | jq -r '.message.raw' | base64 -d | python3 -c "import sys, quopri; print(quopri.decodestring(sys.stdin.read().encode()).decode())"

Environment

  • gog version: v0.9.0
  • OS: macOS (arm64)
  • Email source: Amazon SES (multipart/alternative with quoted-printable encoding)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions