Repository navigation
Fix international search encoding - #188
Merged
Merged
Conversation
There was a problem hiding this comment.
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.
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.
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éorR&Dwould 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-8when 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.