Skip to content

Fix subscriber requests that address the wrong member via the URL - #66

Open
pcbeingused333 wants to merge 2 commits into
Rails-Designer:mainfrom
pcbeingused333:fix/encode-email-in-subscriber-urls
Open

pcbeingused333 wants to merge 2 commits into
Rails-Designer:mainfrom
pcbeingused333:fix/encode-email-in-subscriber-urls

Conversation

@pcbeingused333

@pcbeingused333 pcbeingused333 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Four subscriber providers build a request URL from the raw email and end up addressing the wrong member.

Buttondown, Mailerlite, Beehiiv — not URL-encoded

request(:delete, "#{ENDPOINT_URL}/#{email}")                          # Buttondown, Mailerlite
request(:get, "#{ENDPOINT_URL}/#{publication_id}/subscriptions?email=#{email}")  # Beehiiv

A Gmail-style +tag address is mangled — + decodes to a space in a query string and is ambiguous in a path:

Courrier::Subscriber::Buttondown.new(api_key: k).destroy("user+news@gmail.com")
# DELETE .../subscribers/user+news@gmail.com  -> wrong subscriber or 404

Subscriber::Brevo#destroy already guards this with URI.encode_www_form_component; these three now do the same.

Mailchimp — wrong identifier entirely

Mailchimp's List Members API keys a member by the MD5 hash of the lowercased email, so DELETE .../members/#{email} never matches and always 404s. It now hashes the address before building the path.

Tests

New test/courrier/subscriber/url_encoding_test.rb: a +tag address reaches Buttondown / Mailerlite / Beehiiv URLs as subscriber%2Btag%40example.com, and Mailchimp addresses Subscriber@Example.com by Digest::MD5.hexdigest("subscriber@example.com"). All four fail on main. bundle exec rake and bundle exec standardrb are green (163 runs, 0 failures).

🤖 Generated with Claude Code

pcbeingused333 and others added 2 commits September 8, 2026 18:40
… requests

These three build a request URL by interpolating the raw email into a
path segment or query string:

  request(:delete, "#{ENDPOINT_URL}/#{email}")
  request(:get, ".../subscriptions?email=#{email}")

A `+tag` address (`user+news@gmail.com`, very common) is then mangled:
`+` means a space in a query string and is ambiguous in a path, so the
call addresses the wrong subscriber or 404s. `Subscriber::Brevo` already
runs the identifier through `URI.encode_www_form_component`; the other
three now do the same.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtYgwYNfJ3wHrw9xrooVoB
… email

Mailchimp's List Members API keys a member by the MD5 hash of the
lowercased email address, so `DELETE .../members/#{email}` never matches
and always 404s. Hash the address before building the path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GtYgwYNfJ3wHrw9xrooVoB
@pcbeingused333 pcbeingused333 changed the title URL-encode the email in Buttondown, Mailerlite and Beehiiv subscriber requests Fix subscriber requests that address the wrong member via the URL Sep 8, 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.

1 participant