my $self = { @_ };
bless $self, $class;
+ foreach (keys %$self) {
+ next unless defined $self->{$_};
+ if (uc $self->{$_} eq 'YES') {
+ $self->{$_} = 1;
+ } elsif (uc $self->{$_} eq 'NO') {
+ $self->{$_} = 0;
+ }
+ }
+
# the IMAP state: one of 'UNAUTH', 'AUTH', 'SELECTED' or 'LOGOUT'
# (cf RFC 3501 section 3)
$self->{_STATE} = '';
open STDOUT, '>&', $wd or $self->panic("Can't dup: $!");
my $stderr2;
- if (uc ($self->{'null-stderr'} // 'NO') eq 'YES') {
+ if ($self->{'null-stderr'} // 0) {
open $stderr2, '>&', *STDERR;
open STDERR, '>', '/dev/null' or $self->panic("Can't open /dev/null: $!");
}
$self->{_STATE} = 'UNAUTH';
my @caps = $self->capabilities();
- if ($self->{type} eq 'imap' and uc $self->{STARTTLS} ne 'NO') { # RFC 2595 section 5.1
+ if ($self->{type} eq 'imap' and $self->{STARTTLS}) { # RFC 2595 section 5.1
$self->fail("Server did not advertise STARTTLS capability.")
unless grep {$_ eq 'STARTTLS'} @caps;
$self->_start_ssl($self->{STDIN}) if $self->{type} eq 'imaps';
$self->{_STATE} = 'AUTH';
# Don't send the COMPRESS command before STARTTLS or AUTH, as per RFC 4978
- if (uc ($self->{compress} // 'NO') eq 'YES' and
+ if ($self->{compress} // 1 and
my @algos = grep defined, map { /^COMPRESS=(.+)/i ? uc $1 : undef } @{$self->{_CAPABILITIES}}) {
my @supported = qw/DEFLATE/; # supported compression algorithms
my $algo = first { my $x = $_; grep {$_ eq $x} @algos } @supported;
my $fpr = delete $self->{SSL_fingerprint};
my $vrfy = delete $self->{SSL_verify_trusted_peer};
- $sslargs{SSL_verify_mode} = uc ($vrfy // 'YES') ne 'NO' ? Net::SSLeay::VERIFY_PEER()
- : Net::SSLeay::VERIFY_NONE();
+ $sslargs{SSL_verify_mode} = ($vrfy // 1) ? Net::SSLeay::VERIFY_PEER() : Net::SSLeay::VERIFY_NONE();
$sslargs{$_} = $self->{$_} foreach grep /^SSL_/, keys %$self;
IO::Socket::SSL->start_SSL($socket, %sslargs)
$line = substr($command, $offset, $idx-1-$offset);
$litlen = $litplus ? ($line =~ s/\{([0-9]+)\}\z/{$1+}/ ? $1 : $self->panic())
: ($line =~ /\{([0-9]+)\}\z/ ? $1 : $self->panic());
- $z_flush2 = ($litlen > 4096 and # large literal
- (uc ($self->{'use-binary'} // 'YES') eq 'NO'
- or $line =~ /~\{[0-9]+\}\z/) # literal8, RFC 3516 BINARY
+ $z_flush2 = ($litlen > 4096 and # large literal
+ ($self->{'use-binary'} // 1 or $line =~ /~\{[0-9]+\}\z/) # literal8, RFC 3516 BINARY
) ? 1 : 0;
}
$self->logger('C: ', ($offset == 0 ? "$tag " : '[...]'), $line) if $self->{debug};