Skip to content

Fix literal subscriber search - #3169

Open
mherzog4 wants to merge 1 commit into
knadh:masterfrom
mherzog4:fix/subscriber-literal-search
Open

Fix literal subscriber search#3169
mherzog4 wants to merge 1 commit into
knadh:masterfrom
mherzog4:fix/subscriber-literal-search

Conversation

@mherzog4

Copy link
Copy Markdown

Summary

Treat the subscriber search parameter as a case-insensitive literal substring across listing, count, CSV export, and bulk-action queries.

Root cause

The simple search value was passed directly to PostgreSQL’s ~* regex operator. In a valid subaddress such as user+subaddr@example.net, + is interpreted as a regex quantifier instead of a literal character, so searching for the exact email returns no rows. Other regex metacharacters can likewise change the meaning of a normal text search.

This replaces the regex comparisons with STRPOS(LOWER(column), LOWER(search)) > 0. The separate advanced SQL-expression query feature is unchanged, and this PR does not touch the admin frontend currently being replaced for v7.

Verification

  • PostgreSQL regression check: the old comparison returned false for user+subaddr@example.net; the new comparison returned true
  • Local GET /api/subscribers returned the seeded plus-address subscriber with total: 1
  • Local GET /api/subscribers/export exported that subscriber
  • Local PUT /api/subscribers/query/lists matched that subscriber and added the requested confirmed subscription
  • go test ./...
  • go vet ./...
  • go build -o /tmp/listmonk-build ./cmd
  • git diff --check

Closes #3167

AI disclosure

This contribution was developed with AI assistance (Codex).

@mherzog4
mherzog4 marked this pull request as ready for review July 28, 2026 00:23
@knadh knadh self-assigned this Jul 28, 2026
@knadh knadh added the hodor-review Automated AI code review label Jul 28, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Issues Found

No issues found.

Summary

Total issues: 0 critical, 0 important, 0 minor.

Overall Verdict

Status: Patch is correct

Explanation: The diff cleanly replaces regex-based search on subscriber name/email with a case-insensitive literal substring check using STRPOS(LOWER(...), LOWER($n)) across the affected queries. The SQL remains syntactically valid and preserves the existing parameter/CASE logic without introducing new correctness or safety issues.


Review generated by Hodor (model: gpt-5.2)

Review Metrics — 6 turns, 5 tool calls, 41s

  • Tokens: in 4.7K | cached 22.0K | out 2.2K (total 28.9K)
  • Cost: $0.0422

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hodor-review Automated AI code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Email addresses containing '+' cannot be searched for

2 participants