}
#ifndef CURL_DISABLE_CRYPTO_AUTH
else if((pop3c->authtypes & POP3_TYPE_APOP) &&
- (pop3c->preftype & POP3_TYPE_APOP) &&
- (pop3c->apoptimestamp))
+ (pop3c->preftype & POP3_TYPE_APOP))
/* Perform APOP authentication */
result = pop3_perform_apop(conn);
#endif
result = CURLE_FTP_WEIRD_SERVER_REPLY;
}
else {
- /* Look for the APOP timestamp */
+ /* Does the server support APOP authentication? */
if(len >= 4 && line[len - 2] == '>') {
+ /* Look for the APOP timestamp */
for(i = 3; i < len - 2; ++i) {
if(line[i] == '<') {
/* Calculate the length of the timestamp */
/* Copy the timestamp */
memcpy(pop3c->apoptimestamp, line + i, timestamplen);
pop3c->apoptimestamp[timestamplen] = '\0';
+
+ /* Store the APOP capability */
+ pop3c->authtypes |= POP3_TYPE_APOP;
break;
}
}
else if(len >= 4 && !memcmp(line, "USER", 4))
pop3c->authtypes |= POP3_TYPE_CLEARTEXT;
- /* Does the server support APOP authentication? */
- else if(len >= 4 && !memcmp(line, "APOP", 4))
- pop3c->authtypes |= POP3_TYPE_APOP;
-
/* Does the server support SASL based authentication? */
else if(len >= 5 && !memcmp(line, "SASL ", 5)) {
pop3c->authtypes |= POP3_TYPE_SASL;
}
#ifndef CURL_DISABLE_CRYPTO_AUTH
else if((pop3c->authtypes & POP3_TYPE_APOP) &&
- (pop3c->preftype & POP3_TYPE_APOP) &&
- (pop3c->apoptimestamp))
+ (pop3c->preftype & POP3_TYPE_APOP))
/* Perform APOP authentication */
result = pop3_perform_apop(conn);
#endif
sub CAPA_pop3 {
my ($testno) = @_;
+ my @list = ();
+ my $mechs;
- if((!@capabilities) && (!@auth_mechs)) {
+ # Calculate the capability list based on the specified capabilities
+ # (except APOP) and any authentication mechanisms
+ for my $c (@capabilities) {
+ push @list, "$c\r\n" unless $c eq "APOP";
+ }
+
+ for my $am (@auth_mechs) {
+ if(!$mechs) {
+ $mechs = "$am";
+ }
+ else {
+ $mechs .= " $am";
+ }
+ }
+
+ if($mechs) {
+ push @list, "SASL $mechs\r\n";
+ }
+
+ if(!@list) {
sendcontrol "-ERR Unrecognized command\r\n";
}
else {
my @data = ();
- my $mechs;
# Calculate the CAPA response
push @data, "+OK List of capabilities follows\r\n";
- for my $c (@capabilities) {
- push @data, "$c\r\n";
- }
-
- for my $am (@auth_mechs) {
- if(!$mechs) {
- $mechs = "$am";
- }
- else {
- $mechs .= " $am";
- }
- }
-
- if($mechs) {
- push @data, "SASL $mechs\r\n";
+ for my $l (@list) {
+ push @data, "$l\r\n";
}
push @data, "IMPLEMENTATION POP3 pingpong test server\r\n";