Skip to content

Fix international search encoding - #188

Merged
stevebauman merged 1 commit into
v2.0from
feature/v2-international-search
Sep 28, 2026
Merged

stevebauman merged 1 commit into
v2.0from
feature/v2-international-search

Conversation

@stevebauman

Copy link
Copy Markdown
Member

This PR fixes searches containing international characters or ampersands. Search values were being encoded using modified UTF-7, which is intended for mailbox names. For example, searching for café or R&D would send a different value to the server.

Search and sort queries now preserve the original text and send non-ASCII values as byte-counted UTF-8 literals. SEARCH includes CHARSET UTF-8 when required, accounting for enabled UTF-8 support and whether the session is using IMAP4rev1 or IMAP4rev2. Nested conditions, empty strings, and "0" values are preserved.

Validated with the full unit suite: 827 tests passing. Formatting and diff checks pass. Live-server integration tests have not been run.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation consistently preserves search text, follows session charset rules, and includes focused regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes international IMAP search and sort encoding by using byte-counted UTF-8 literals and session-appropriate charset handling.

Changes:

  • Compiles search criteria into literal-aware command tokens.
  • Handles UTF-8 charset rules for rev1, rev2, and UTF8-enabled sessions.
  • Adds coverage for international, nested, empty, and zero-valued criteria.
File Description
src/​Connection/​ImapCommand.php Supports closing grouped expressions after literals.
src/​Connection/​ImapQueryBuilder.php Compiles preserved search values into tokens and UTF-8 literals.
src/​MessageQuery.php Sends tokens with capability-aware charset handling.
src/​QueriesMessages.php Exposes compiled tokens through query wrappers.
src/​Support/​Str.php Adds ASCII detection.
tests/​Unit/​Connection/​ImapQueryBuilderTest.php Covers encoding and nested expressions.
tests/​Unit/​MessageQueryTest.php Covers transmitted search and sort commands.
tests/​Unit/​Testing/​FakeMessageQueryTest.php Verifies fake-query token forwarding.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@stevebauman
stevebauman merged commit f80844d into v2.0 Sep 28, 2026
14 checks passed
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.

2 participants