fix: exclude /pmta tracking links from safepath check (fixes #338) - #354
Open
srmdn wants to merge 1 commit into
Open
fix: exclude /pmta tracking links from safepath check (fixes #338)#354srmdn wants to merge 1 commit into
srmdn wants to merge 1 commit into
Conversation
…ail#338) Tracking links (/pmta/*) return 404 when safepath is enabled because the safepath middleware blocks requests that lack the safe_path_pass session cookie. Click/open tracking in marketing emails breaks when recipients open links in incognito windows or forward emails (no safepath cookie set). Fix: add /pmta to the safepath excludesURIs for exact match, and add a excludedURIPrefixes list for prefix matching /pmta/* paths (tracking IDs are appended to the path). Tested: go build, go vet clean, 1275 unit tests pass. Signed-off-by: srmdn <mail@saidwp.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When safepath is enabled, click/open tracking links (
/pmta/*) return 404 for recipients who open emails in incognito/private windows or forwarded emails — they lack thesafe_path_passsession cookie.Root Cause
The safepath middleware in
core/internal/cmd/cmd.goblocks all requests without thesafe_path_passcookie. The/pmtatracking endpoints are not in theexcludesURIswhitelist, so tracking links get 404.Fix
/pmtato theexcludesURIsexact-match mapexcludedURIPrefixeslist with/pmta/for prefix matching — tracking links include encrypted IDs after the path prefix (e.g.,/pmta/ENCRYPTED_ID)Testing
go build ./core/...— compiles cleango vet ./core/...— no issuesgo test -count=1 -short ./internal/...— 1,275 tests passRelated
Fixes #338
Signed-off-by: srmdn mail@saidwp.com