diff --git a/ChangeLog b/ChangeLog index 323e718..4aa2e18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,15 +1,26 @@ RCS file: RCS/imapsync,v Working file: imapsync -head: 1.164 +head: 1.166 branch: locks: strict access list: symbolic names: keyword substitution: kv -total revisions: 164; selected revisions: 164 +total revisions: 166; selected revisions: 166 description: ---------------------------- +revision 1.166 +date: 2006/03/30 02:22:39; author: gilles; state: Exp; lines: +30 -30 +Use of parse_headers() instead of parse_headers() +Finished to fix bug "word too long" by splitting request +also in parse_headers2() function. +---------------------------- +revision 1.165 +date: 2006/03/30 01:41:22; author: gilles; state: Exp; lines: +125 -9 +Fixed a bug with interactive passwords (it was not used...) +Added function parse_headers2() from IMAPClient.pm +---------------------------- revision 1.164 date: 2006/03/26 03:17:48; author: gilles; state: Exp; lines: +97 -9 Fixed the bug "Word too large" by spliting requests on diff --git a/README b/README index 8749708..c8c69c2 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ NAME imapsync - IMAP synchronization, copy or migration tool. Synchronize mailboxes between two imap servers. Good at IMAP migration. - $Revision: 1.164 $ + $Revision: 1.166 $ INSTALL imapsync works fine under any Unix OS. @@ -287,5 +287,5 @@ AUTHOR teaching free open and gratis softwares. Don't hesitate to pay him for that services. - $Id: imapsync,v 1.164 2006/03/26 03:17:48 gilles Exp $ + $Id: imapsync,v 1.166 2006/03/30 02:22:39 gilles Exp $ diff --git a/VERSION b/VERSION index fa954c7..029298c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.164 +1.166 diff --git a/freshmeat_submition b/freshmeat_submition index a2e317d..8b8e937 100644 --- a/freshmeat_submition +++ b/freshmeat_submition @@ -1,10 +1,8 @@ Project: imapsync -Version: 1.163 -Release-Focus: Minor feature enhancements +Version: 1.164 +Release-Focus: Major bugfixes Hide: Y Home-Page-URL: http://www.linux-france.org/prj/imapsync/ Gzipped-Tar-URL: http://www.linux-france.org/prj/imapsync/dist/ -Fixed the bug "Word too large" by spliting requests on -demand with --split1 and --split2 options. - +Code cleanup. diff --git a/imapsync b/imapsync index d4a3842..8c69cb5 100755 --- a/imapsync +++ b/imapsync @@ -6,7 +6,7 @@ imapsync - IMAP synchronization, copy or migration tool. Synchronize mailboxes between two imap servers. Good at IMAP migration. -$Revision: 1.164 $ +$Revision: 1.166 $ =head1 INSTALL @@ -337,7 +337,7 @@ Gilles LAMIRAL earn his living writing, installing, configuring and teaching free open and gratis softwares. Don't hesitate to pay him for that services. -$Id: imapsync,v 1.164 2006/03/26 03:17:48 gilles Exp $ +$Id: imapsync,v 1.166 2006/03/30 02:22:39 gilles Exp $ =cut @@ -392,7 +392,7 @@ my( use vars qw ($opt_G); # missing code for this will be option. -$rcs = ' $Id: imapsync,v 1.164 2006/03/26 03:17:48 gilles Exp $ '; +$rcs = ' $Id: imapsync,v 1.166 2006/03/30 02:22:39 gilles Exp $ '; $rcs =~ m/,v (\d+\.\d+)/; $VERSION = ($1) ? $1 : "UNKNOWN"; @@ -429,8 +429,8 @@ $error=0; my $banner = join("", '$RCSfile: imapsync,v $ ', - '$Revision: 1.164 $ ', - '$Date: 2006/03/26 03:17:48 $ ', + '$Revision: 1.166 $ ', + '$Date: 2006/03/30 02:22:39 $ ', "\n", "Mail::IMAPClient version used here is ", $VERSION_IMAPClient,"\n" @@ -527,13 +527,13 @@ sub ask_for_password { $password1 || $passfile1 || do { - ask_for_password($authuser1 || $user1, $host1); + $password1 = ask_for_password($authuser1 || $user1, $host1); }; $password1 = (defined($passfile1)) ? firstline ($passfile1) : $password1; $password2 || $passfile2 || do { - ask_for_password($authuser2 || $user2, $host2); + $password2 = ask_for_password($authuser2 || $user2, $host2); }; $password2 = (defined($passfile2)) ? firstline ($passfile2) : $password2; @@ -944,11 +944,11 @@ FOLDER: foreach my $f_fold (@f_folders) { my %f_hash = (); my %t_hash = (); - + print "++++ From [$f_fold] Parse 1 ++++\n"; - my $f_heads = $from->parse_headers($from->Range([@f_msgs]),@useheader) - if (@f_msgs) ; + my $f_heads = $from->parse_headers2([@f_msgs], + @useheader)if (@f_msgs) ; $debug and print "Time headers: ", timenext(), " s\n"; my $f_fir = $from->fetch_hash2("FLAGS", "INTERNALDATE", @@ -961,8 +961,8 @@ FOLDER: foreach my $f_fold (@f_folders) { $debug and print "Time headers: ", timenext(), " s\n"; print "++++ To [$t_fold] Parse 1 ++++\n"; - my $t_heads = $to->parse_headers($to->Range([@t_msgs]),@useheader) - if (@t_msgs); + my $t_heads = $to->parse_headers2([@t_msgs], + @useheader) if (@t_msgs); $debug and print "Time headers: ", timenext(), " s\n"; my $t_fir = $to->fetch_hash2("FLAGS", "INTERNALDATE", @@ -1459,7 +1459,7 @@ sub Split { } - +# From IMAPClient.pm sub fetch_hash2 { # taken from original lib, # just added split code. @@ -1527,3 +1527,119 @@ sub fetch_hash2 { } return wantarray ? %$hash : $hash; } + + +# From IMAPClient.pm +sub parse_headers2 { + my($self,$msgspec_all,@fields) = @_; + my(%fieldmap) = map { ( lc($_),$_ ) } @fields; + my $msg; my $string; my $field; + + unless(ref($msgspec_all) eq 'ARRAY') { + print "parse_headers2 want an ARRAY ref\n"; + exit 1; + } + + my $headers = {}; # hash from message ids to header hash + my $split = $self->Split() || scalar(@$msgspec_all); + while(my @msgs = splice(@$msgspec_all, 0, $split)) { + print "SPLIT: @msgs\n"; + my $msgspec = \@msgs; + + # Make $msg a comma separated list, of messages we want + $msg = $self->Range($msgspec); + + if ($fields[0] =~ /^[Aa][Ll]{2}$/ ) { + + $string = "$msg body" . + # use ".peek" if Peek parameter is a) defined and true, + # or b) undefined, but not if it's defined and untrue: + + ( defined($self->Peek) ? + ( $self->Peek ? ".peek" : "" ) : + ".peek" + ) . "[header]" ; + + } else { + $string = "$msg body" . + # use ".peek" if Peek parameter is a) defined and true, or + # b) undefined, but not if it's defined and untrue: + + ( defined($self->Peek) ? + ( $self->Peek ? ".peek" : "" ) : + ".peek" + ) . "[header.fields (" . join(" ",@fields) . ')]' ; + } + + my @raw=$self->fetch( $string ) or return undef; + + + my $h = 0; # reference to hash of current msgid, or 0 between msgs + + for my $header (map { split(/(?:\x0d\x0a)/,$_) } @raw) { + local($^W) = undef; + if ( $header =~ /^\*\s+\d+\s+FETCH\s+\(.*BODY\[HEADER(?:\]|\.FIELDS)/i) { + if ($self->Uid) { + if ( my($msgid) = $header =~ /UID\s+(\d+)/ ) { + $h = {}; + $headers->{$msgid} = $h; + } else { + $h = {}; + } + } else { + if ( my($msgid) = $header =~ /^\*\s+(\d+)/ ) { + #start of new message header: + $h = {}; + $headers->{$msgid} = $h; + } + } + } + next if $header =~ /^\s+$/; + + # ( for vi + if ($header =~ /^\)/) { # end of this message + $h = 0; # set to be between messages + next; + } + # check for 'UID)' + # when parsing headers by UID. + if ($self->Uid and my($msgid) = $header =~ /^\s*UID\s+(\d+)\s*\)/) { + $headers->{$msgid} = $h; # store in results against this message + $h = 0; # set to be between messages + next; + } + + if ($h != 0) { # do we expect this to be a header? + my $hdr = $header; + chomp $hdr; + $hdr =~ s/\r$//; + if ($hdr =~ s/^(\S+):\s*//) { + $field = exists $fieldmap{lc($1)} ? $fieldmap{lc($1)} : $1 ; + push @{$h->{$field}} , $hdr ; + } elsif ($hdr =~ s/^.*FETCH\s\(.*BODY\[HEADER\.FIELDS.*\)\]\s(\S+):\s*//) { + $field = exists $fieldmap{lc($1)} ? $fieldmap{lc($1)} : $1 ; + push @{$h->{$field}} , $hdr ; + } elsif ( ref($h->{$field}) eq 'ARRAY') { + + $hdr =~ s/^\s+/ /; + $h->{$field}[-1] .= $hdr ; + } + } + } + my $candump = 0; + if ($self->Debug) { + eval { + require Data::Dumper; + Data::Dumper->import; + }; + $candump++ unless $@; + } + + } + # if we asked for one message, just return its hash, + # otherwise, return hash of numbers => header hash + # if (ref($msgspec) eq 'ARRAY') { + + return $headers; + +} diff --git a/tests.sh b/tests.sh index 0b1f10f..fa5c391 100644 --- a/tests.sh +++ b/tests.sh @@ -1,6 +1,6 @@ #!/bin/sh -# $Id: tests.sh,v 1.50 2006/03/25 22:22:53 gilles Exp $ +# $Id: tests.sh,v 1.51 2006/03/30 02:22:56 gilles Exp $ #### Shell pragmas @@ -730,6 +730,9 @@ lp_authuser() { fi } + + + lp_authmech_LOGIN() { if test X`hostname` = X"plume"; then echo3 Here is plume