Bug #14566 [Fbk]: Error in parsing protocol
| From: | ken at linux dot ie | Date: | Mon, 23 Mar 2009 10:18:51 +0000 |
| Subject: | Bug #14566 [Fbk]: Error in parsing protocol | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-234@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=14566&edit=1
ID: 14566
Updated by: ken@linux.ie
Reported By: pahan at hubbitus dot spb dot su
Summary: Error in parsing protocol
Status: Feedback
Type: Bug
Package: Net_IMAP
Operating System: Linux
Package Version: 1.0.3
PHP Version: Irrelevant
Assigned To: hudeldudel
Roadmap Versions:
New Comment:
running the test script as is I get the following:
ken:~$ php test_imap.php
Fatal error: Cannot use object of type PEAR_Error as array in
/usr/share/php/Net/IMAPProtocol.php on line 1038
Call Stack:
0.0003 121672 1. {main}() /home/ken/test_imap.php:0
0.0320 2790744 2. Net_IMAP->getNumberOfMessages()
/home/ken/test_imap.php:26
0.0320 2790744 3. Net_IMAPProtocol->cmdStatus()
/usr/share/php/Net/IMAP.php:979
The return value from _genericCommand is not being checked for whether
it is valid or a PEAR Error...
The error message is "not connected!" btw.
the amended/working test script should look like:
require_once('Net/IMAP.php');
static $mailbox = 'inbox';
static $loginCount = 0;
$user="example";
$passwd="password";
$host="localhost";
$port="143";
$imap= new Net_IMAP($host,$port);
$authMethod=false;
if ( PEAR::isError( $ret = $imap->login( $user , $passwd , $authMethod
) ) ) {
echo "Unable to login! reason:" . $ret->getMessage() . "\n";
exit();
}
$imap->selectMailbox( $mailbox );
if ( !PEAR::isError( $num_messages = $imap->getNumberOfMessages(
$mailbox ) ) ){
for($i=1; $i <= $num_messages; $i++) {
if (! $imap->isDeleted($i)){//ANSWER!
$curMsg = $imap->getSummary($i);
var_dump($curMsg);
} else {
echo "Or $mailbox has no messages or there was an
error!\n";
}
}
}
which, incidentally, works fine for me.
I think, perhaps, this bug got fixed in the 1.1.0beta2 release (dated
2008-03-09) - maybe it should be marked as stable? ;-)
Previous Comments:
------------------------------------------------------------------------
[2009-01-15 10:01:44] doconnor
Hey if this one is fixed in CVS, can you link to a previous bug? Also,
what are the chances of it becoming a release?
------------------------------------------------------------------------
[2008-12-10 10:02:03] hudeldudel
Thank you for taking the time to report a problem with the package.
This problem may have been already fixed by a previous change that
is in the CVS of the package. Please log into CVS with:
cvs -d :pserver:cvsread@cvs.php.net:/repository login
and check out the CVS repository of this package and upgrade
cvs -d :pserver:cvsread@cvs.php.net:/repository co pear/Net_IMAP
pear upgrade pear/Net_IMAP/package2.xml
or
pear upgrade pear/Net_IMAP/package.xml
If you are able to reproduce the bug with the latest CVS,
please change the status back to "Open".
Again, thank you for your continued support of PEAR.
I can not reproduce with current CVS version.
Your description looks like problems with wrong clocing braces fixed
some time ago in CVS.
regards
------------------------------------------------------------------------
[2008-08-26 15:24:12] hubbitus
Description:
------------
After call method getSummary():
PHP Notice: Uninitialized string offset: 214 in
/usr/share/pear/Net/IMAPProtocol.php on line 2185
Notice: Uninitialized string offset: 214 in
/usr/share/pear/Net/IMAPProtocol.php on line 2185
PHP Notice: Uninitialized string offset: 214 in
/usr/share/pear/Net/IMAPProtocol.php on line 2193
Notice: Uninitialized string offset: 214 in
/usr/share/pear/Net/IMAPProtocol.php on line 2193
PHP Notice: Uninitialized string offset: 215 in
/usr/share/pear/Net/IMAPProtocol.php on line 2199
Notice: Uninitialized string offset: 215 in
/usr/share/pear/Net/IMAPProtocol.php on line 2199
PHP Notice: Uninitialized string offset: 215 in
/usr/share/pear/Net/IMAPProtocol.php on line 2200
Notice: Uninitialized string offset: 215 in
/usr/share/pear/Net/IMAPProtocol.php on line 2200
2200,/usr/share/pear/Net/IMAPProtocol.php,PROTOCOL
ERROR!:_getClosingBracesPos: must be a ) but is a
''|POS:215|STR_LINE:(NIL NIL {50}
Eleftherios utyihkl" <erabgaar_2001@atnetwork.biz>
"unspecified-domain")) ((NIL NIL "support" "o-range.ru")) NIL NIL NIL
"<001101c904ff$7b7cae30$4bb9825d@PCHuber>"))
A0007 OK Completed (0.000 sec)
!!!!
PHP Fatal error: Maximum function nesting level of '100' reached,
aborting! in /usr/share/pear/Net/IMAPProtocol.php on line 2264
Fatal error: Maximum function nesting level of '100' reached, aborting!
in /usr/share/pear/Net/IMAPProtocol.php on line 2264
==================
Notice warnings is a strange design issues, for example first:
PHP Notice: Uninitialized string offset: 214 in
/usr/share/pear/Net/IMAPProtocol.php on line 2185
On line 2185:
while ( $str_line[$pos] != '"' && $pos < $len ) {
got notice if $str_line hasn't index $post. And it is fixed only by
change order of conditions:
while ( $pos < $len && $str_line[$pos] != '"' ) {
what is more logical in any case.
But PROTOCOL ERROR is more serious. I'm capture tcp-session by
Wireshark and decoded IMAP-answer which do not parsed was:
A0007 FETCH 1 (RFC822.SIZE UID FLAGS ENVELOPE INTERNALDATE)
* 1 FETCH (FLAGS () UID 800181 INTERNALDATE "23-Aug-2008 13:02:24
+0400" RFC822.SIZE 2229 ENVELOPE ("Sat, 23 Aug 2008 11:06:09 +0200"
"Paris Hilton covered in excrement" ((NIL NIL {50}
Eleftherios utyihkl" <erabgaar_2001@atnetwork.biz>
"unspecified-domain")) ((NIL NIL {50}
Eleftherios utyihkl" <erabgaar_2001@atnetwork.biz>
"unspecified-domain")) ((NIL NIL {50}
Eleftherios utyihkl" <erabgaar_2001@atnetwork.biz>
"unspecified-domain")) ((NIL NIL "support" "o-range.ru")) NIL NIL NIL
"<001101c904ff$7b7cae30$4bb9825d@PCHuber>"))
A0007 OK Completed (0.000 sec)
Test script:
---------------
static $mailbox = 'inbox';
static $loginCount = 0;
$imap = new Net_IMAP($host, $port);
$imap->selectMailbox( $mailbox );
if ( !PEAR::isError( $num_messages = $imap->getNumberOfMessages(
$mailbox ) ) ){
for($i=1; $i <= $num_messages; $i++) {
if (! $imap->isDeleted($i)){//ANSWER!
$curMsg = $imap->getSummary($i);
var_dump($curMsg);
}else{
echo "Or $mailbox has no messages or there was an error!\n";
}
Expected result:
----------------
Var_dump of current messages in inbox IMAP-folder.
Actual result:
--------------
Errors. See description.
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=14566&edit=1