Skip Menu |

This queue is for tickets about the Mail-IMAPClient CPAN distribution.

Report information
The Basics
Id: 32398
Status: resolved
Priority: 0/
Queue: Mail-IMAPClient

People
Owner: Nobody in particular
Requestors: Msteltman [...] disway.nl
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: apparent bug in parse_headers with exchange 2003 server
Date: Thu, 17 Jan 2008 22:13:57 +0100
To: <bug-Mail-IMAPClient [...] rt.cpan.org>
From: "Michiel Steltman" <Msteltman [...] disway.nl>
Mark, I'm hesitating to report since I can hardly imagine that I am the only and first one to find this: there must be a substantial number of people who have done what I have tried to do. Anyway, with the risk of getting egg on my face, here is what happens: parse_headers fails without a LastError against an exchange 2003 server, same code works fine against a Cysrus imap server The difference being: * 372 FETCH (BODY[HEADER.FIELDS (X-Bogosity much stuff etc mode UID 100905) Read: 4 OK FETCH completed. for the exchange server, and * 372 FETCH (BODY[HEADER.FIELDS (X-Bogosity much stuff etc ) 4 OK Completed (0.000 sec) for the cyrus server Here is the relevant code snippet: # # Main - # print "Connecting to $imhost as user $id \n" if $opt_v; my $imap = Mail::IMAPClient->new( Server => $imhost, User => $id, Password=> $pw, Peek => 1, IgnoreSizeErrors => 1, Debug => $opt_d||0 ) or die "Cannot connect to imap server $imhost"; $imap->select($Inbox) or die "Cannot select $Inbox"; my @uids = $imap->search($search) || die "No $search messages: nothing to do \n"; # # uids is an array of arryas; msg is array as well # for my $msg (@uids) { print "msg",Data::Dumper::Dumper($msg) if $opt_v; for my $id (@$msg) { my $h = $imap->parse_headers($id, "X-Bogosity","X-Spam-Status","Subject","Reply-to","From") or die "parse_headers failed for $id: \"" . $imap->LastError . " \""; print "hash",Data::Dumper::Dumper($h) if $opt_v ; ---- and the debug output: ------------------ [root@mist imap]# ./st.pl -u mist@xyz.com -p ****** -v -d Connecting to xxxxx as user mist@xyz.com Started at Thu Jan 17 22:00:24 2008 Using Mail::IMAPClient version 3.02 on perl 5.008007 Connecting to xxxxx port 143 Connected to xxxxx Read: * OK Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 ( xxxxxx ) ready. Sending: 1 LOGIN "mist@xyz.com" ******* Sent 37 bytes Read: 1 OK LOGIN completed. Sending: 2 SELECT Inbox Sent 16 bytes Read: * 373 EXISTS * 0 RECENT * FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent) * OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags * OK [UNSEEN 372] Is the first unseen message * OK [UIDVALIDITY 6385] UIDVALIDITY value 2 OK [READ-WRITE] SELECT completed. Sending: 3 UID SEARCH UNSEEN Sent 21 bytes Read: * SEARCH 100905 100920 3 OK SEARCH completed. msg$VAR1 = [ '100905', '100920' ]; Sending: 4 UID FETCH 100905 BODY.PEEK[HEADER.FIELDS (X-Bogosity X-Spam-Status Subject Reply-to From)] Sent 94 bytes LITERAL: received literal in line * 372 FETCH (BODY[HEADER.FIELDS (X-Bogosity X-Spam-Status Subject Reply-to From)] of length 322; attempting to retrieve from the 336 bytes in: X-Bogosity: Unsure, tests=bogofilter, spamicity=0.501899, version=1.1.5 Subject: Five considerations for upgrading to Exchange 2007 Reply-To: TechRepublic Webcasts <CNET_Networks_#3.237736.3931313538363536@newsletters.online.com> From: TechRepublic Webcasts <CNET_Networks_Member_Services@newsletters.online.com> UID 100905) <END_OF_iBuffer> Read: * 372 FETCH (BODY[HEADER.FIELDS (X-Bogosity X-Spam-Status Subject Reply-to From)] X-Bogosity: Unsure, tests=bogofilter, spamicity=0.501899, version=1.1.5 Subject: Five considerations for upgrading to Exchange 2007 Reply-To: TechRepublic Webcasts <CNET_Networks_#3.237736.3931313538363536@newsletters.online.com> From: TechRepublic Webcasts <CNET_Networks_Member_Services@newsletters.online.com> UID 100905) Read: 4 OK FETCH completed. parse_headers failed for 100905: " " at ./st.pl line 112. [root@mist imap]# --------------- Best, Michiel Steltman
Subject: Re: [rt.cpan.org #32398] apparent bug in parse_headers with exchange 2003 server
Date: Sat, 19 Jan 2008 13:47:23 +0100
To: Michiel Steltman via RT <bug-Mail-IMAPClient [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* Michiel Steltman via RT (bug-Mail-IMAPClient@rt.cpan.org) [080117 21:14]: Show quoted text
> Thu Jan 17 16:14:04 2008: Request 32398 was acted upon. > Transaction: Ticket created by Msteltman@disway.nl > Queue: Mail-IMAPClient > Subject: apparent bug in parse_headers with exchange 2003 server > > I'm hesitating to report since I can hardly imagine that I am the only and > first one to find this: there must be a substantial number of people who > have done what I have tried to do. > Anyway, with the risk of getting egg on my face, here is what happens:
(waarschijnlijk kunnen we dit ook in het Nederlands doen, toch?) Show quoted text
> parse_headers fails without a LastError against an exchan 2003 server, > same code works fine against a Cysrus imap server
The cause is very probably line 1884 (in the latest release: 3.03) if($header =~ /^\)/) # end of this message should probably become something more complicated. This might be a clean solution: (Mail/IMAPClient.pm line 1888) # ( for vi if($header =~ /^\)/) # end of this message { undef $h; # inbetween headers next; } + # windows2003, UID after blank line trailing... '(' for vi + elsif($self->Uid && $header =~ /^\s*UID\s+(\d+)\s*\)/) + { $headers->{$1} = $h; # finally found msgid + undef $h; + next; + } Please confirm that it works. -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
problem fixed in 3.04. Thanks for the help