Fix mailbox encoding regression for accented folder names
Commit 0738f13 introduced a regression by hardcoding utf8 encoding instead of using dynamic encoding selection. This breaks compatibility with IMAP servers not announcing UTF8=ACCEPT (like Cyrus), making it impossible to access or create mailboxes with accented characters (e.g., "Envoyé", "testé").
The fix restores dynamic encoding based on $this->_encoding:
- Servers with UTF8=ACCEPT use Mailbox_Utf8 (utf8)
- RFC-compliant servers use Mailbox (utf7imap)
Also adapts testBadInput to handle PHP 8.2+ behavior where mb_convert_encoding now encodes null bytes as '&AAA-' instead of truncating the string.
Fixes: 0738f13 (Fix Mailbox testBadInput test on PHP 8.2)
PR Summary
-
Updated Constructor Use in Mailbox.php Instead of using the previously hardcoded 'utf8' mode, the constructor was updated in
Mailbox.phpto utilize the object's built-in encoding property. This change allows the system to be more flexible and handle different encoding modes. -
Introduced New Test Case in MailboxTest.php This PR includes a new test case in
MailboxTest.php. The objective of this test is to confirm the system's ability to correctly manage null bytes (empty data points). Some recent changes in PHP version 8.2 and later require an adjustment in behaviour which this test verifies. -
Adjusted Assertions in testBadInput() Method The PR involves tweaking assertions (statements of expected results) in the
testBadInput()method. The goal of this update is to cater to the different ways null bytes are handled across various versions of PHP, ensuring the software functions properly, regardless of the PHP version.