DEBUG printf of data immediately before it enters the socket. The mods shown here are the minimal required brute-force test
to regain search function. This is not IMO an advisable way to implement a patch.
Summary conclusion on SEARCH is that office365 does not accept the CHARSET UTF-8 assertion and is further oddly picky about white-space
between tokens (apparently).
Below, Net::IMAP::Client::_send_cmd () indicates the data written to the socket
towards the server.
1: install module on a fresh virtual machine of similar environment.
Linux cos7x64-node5-codepool 3.10.0-1127.8.2.el7.x86_64 #1 SMP Tue May 12 16:57:42 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Module < Net::IMAP::Client (GANGLION/Net-IMAP-Client-0.9505.tar.gz)
>> /usr/bin/make install -- OK
// test code minus sensitive information.
$imap->login || die('Login failed: ' . $imap->last_error);
$imap->select( 'ACL' ) || die("$!");
my $messages = $imap->search('ALL');
printf("%s: %s\n", "Dumping retval from imap->search('ALL')" , Dumper($messages));
2: Open a session to outlook.office365.com. Dump return value from $imap->search('ALL').
perl -w imap_test.pl
Dumping retval from imap->search('ALL'): $VAR1 = undef;
3: remove charset assertion
diff /root/perl5/lib/perl5/Net/IMAP/Client.pm /root/.cpan/build/Net-IMAP-Client-0.9505-4FBM27/lib/Net/IMAP/Client.pm
300c300
< $charset = '';
---
Show quoted text>
perl -w imap_test.pl
Dumping retval from imap->search('ALL'): $VAR1 = undef;
4. Put 'charset' back. Add debug.
diff /root/perl5/lib/perl5/Net/IMAP/Client.pm /root/.cpan/build/Net-IMAP-Client-0.9505-4FBM27/lib/Net/IMAP/Client.pm
300c300
<
---
Show quoted text>
681c681
< my($__PACKAGE__,$__FILE__,$__LINE__,$__FUNCTION__) = caller(0);
---
Show quoted text>
702d701
< printf("%s %s %s %s\n", $__FUNCTION__, $__LINE__, 'cmd', $cmd) if ($cmd !~ /LOGIN/);
707d705
< printf("%s %s %s %s\n", $__FUNCTION__, $__LINE__, 'cmd', $cmd) if ($cmd !~ /LOGIN/);
Run test.
perl -w imap_test.pl
Net::IMAP::Client::_send_cmd 800 cmd NIC2 SELECT "ACL"
Net::IMAP::Client::_send_cmd 800 cmd NIC3 UID SEARCH CHARSET UTF-8 ALL
Dumping retval from imap->search('ALL'): $VAR1 = undef;
Net::IMAP::Client::_send_cmd 82 cmd NIC4 LOGOUT
5. Manually remove CHARSET UTF8 ALL immediately prior to socket with a regex.
diff /root/perl5/lib/perl5/Net/IMAP/Client.pm /root/.cpan/build/Net-IMAP-Client-0.9505-4FBM27/lib/Net/IMAP/Client.pm
300c300
<
---
Show quoted text>
681c681
< my($__PACKAGE__,$__FILE__,$__LINE__,$__FUNCTION__) = caller(0);
---
Show quoted text>
702,705d701
< $cmd =~ s/CHARSET//g;
< $cmd =~ s/UTF-8//g;
< $cmd =~ s/\+/ /g;
< printf("%s %s %s %s\n", $__FUNCTION__, $__LINE__, 'cmd', $cmd) if ($cmd !~ /LOGIN/);
710d705
< printf("%s %s %s %s\n", $__FUNCTION__, $__LINE__, 'cmd', $cmd) if ($cmd !~ /LOGIN/);
Retest.
perl -w imap_test.pl
Net::IMAP::Client::_send_cmd 803 cmd NIC2 SELECT "ACL"
Net::IMAP::Client::_send_cmd 803 cmd NIC3 UID SEARCH ALL
Dumping retval from imap->search('ALL'): $VAR1 = undef;
Net::IMAP::Client::_send_cmd 82 cmd NIC4 LOGOUT
6. Collapse the extra white-space in the data that was written to the socket. Leave one space behind.
$cmd =~ s/\s+ALL/ ALL/g below.
300c300
<
---
Show quoted text>
681c681
< my($__PACKAGE__,$__FILE__,$__LINE__,$__FUNCTION__) = caller(0);
---
Show quoted text>
702,705d701
< $cmd =~ s/CHARSET//g;
< $cmd =~ s/UTF-8//g;
< $cmd =~ s/\s+ALL/ ALL/g;
< printf("%s %s %s %s\n", $__FUNCTION__, $__LINE__, 'cmd', $cmd) if ($cmd !~ /LOGIN/);
710d705
< printf("%s %s %s %s\n", $__FUNCTION__, $__LINE__, 'cmd', $cmd) if ($cmd !~ /LOGIN/);
SUCCESS. This seems to support the conclusion that office365 does not either like extraneous white space,
OR the CHARSET assertion.
perl -w imap_test.pl
Net::IMAP::Client::_send_cmd 803 cmd NIC2 SELECT "ACL"
Net::IMAP::Client::_send_cmd 803 cmd NIC3 UID SEARCH ALL
Dumping retval from imap->search('ALL'): $VAR1 = [
1,
2,
3,
4,
5,
6,
7,
8,
9
];
Net::IMAP::Client::_send_cmd 82 cmd NIC4 LOGOUT
7. Put back CHARSET UTF-8 as a final test.
diff /root/perl5/lib/perl5/Net/IMAP/Client.pm /root/.cpan/build/Net-IMAP-Client-0.9505-4FBM27/lib/Net/IMAP/Client.pm
300c300
<
---
Show quoted text>
681c681
< my($__PACKAGE__,$__FILE__,$__LINE__,$__FUNCTION__) = caller(0);
---
Show quoted text>
702,705d701
< # $cmd =~ s/CHARSET//g;
< # $cmd =~ s/UTF-8//g;
< $cmd =~ s/\s+ALL/ ALL/g;
< printf("%s %s %s %s\n", $__FUNCTION__, $__LINE__, 'cmd', $cmd) if ($cmd !~ /LOGIN/);
710d705
< printf("%s %s %s %s\n", $__FUNCTION__, $__LINE__, 'cmd', $cmd) if ($cmd !~ /LOGIN/);
perl -w imap_test.pl
Result: FAILURE.
Net::IMAP::Client::_send_cmd 803 cmd NIC2 SELECT "ACL"
Net::IMAP::Client::_send_cmd 803 cmd NIC3 UID SEARCH CHARSET UTF-8 ALL
Dumping retval from imap->search('ALL'): $VAR1 = undef;
Net::IMAP::Client::_send_cmd 82 cmd NIC4 LOGOUT
Put back white-space removal.
try a SEEN search.
diff /root/perl5/lib/perl5/Net/IMAP/Client.pm /root/.cpan/build/Net-IMAP-Client-0.9505-4FBM27/lib/Net/IMAP/Client.pm
300c300
<
---
Show quoted text>
681c681
< my($__PACKAGE__,$__FILE__,$__LINE__,$__FUNCTION__) = caller(0);
---
Show quoted text>
702,706d701
< $cmd =~ s/CHARSET//g;
< $cmd =~ s/UTF-8//g;
< $cmd =~ s/\s+ALL/ ALL/g;
< $cmd =~ s/\s+SEEN/ SEEN/g;
< printf("%s %s %s %s\n", $__FUNCTION__, $__LINE__, 'cmd', $cmd) if ($cmd !~ /LOGIN/);
711d705
< printf("%s %s %s %s\n", $__FUNCTION__, $__LINE__, 'cmd', $cmd) if ($cmd !~ /LOGIN/);
SUCCESS
perl -w imap_test.pl
Net::IMAP::Client::_send_cmd 804 cmd NIC2 SELECT "ACL"
Net::IMAP::Client::_send_cmd 804 cmd NIC3 UID SEARCH SEEN
Dumping retval from imap->search('ALL'): $VAR1 = [
1,
2,
3,
4,
5,
6,
7,
8,
9
];
Net::IMAP::Client::_send_cmd 82 cmd NIC4 LOGOUT