ZF-7547: Zend_Mail_Protocol_Imap::_decodeLine incorrectly parses some kind of strings

Description

For example, call $imap->_decodeLine('("A B C")') returns array('"A', 'B', 'C"') instead of array('"A B C"')

In the same time calls like $imap->_decodeLine('(X "A B C")') are working fine: array('X', '"A B C"')

$imap is an instance of Zend_Mail_Protocol_Imap (visibility modifier changed from protected to public for testing purposes).

This bug affects IMAP responses parsing and makes IMAP using almost impossible. For example, IMAP request like "FETCH 1 (ENVELOPE)" returns garbage instead of valid envelope.

Comments

The problem could be saved by replacing line

if (preg_match('%^"((.|\\|\")*?)" *%', $line, $matches)) {

with

if (preg_match('%^("((.|\\|\")?)" *%', $line, $matches)) {

added '(*'

proposed fix for Zend/Mail/Protocol/Imap.php

Memo: unit test Zend/Mail/ImapTest.php uses Zend/Mail/Protocol/Imap.php.

Moved to correct component

Solved in SVN r18976(trunk), r18977(1.9 branch)