smtp: Support UTF-8 based host names in the RCPT TO command

This commit is contained in:
Steve Holme 2020-02-08 00:14:57 +00:00
parent 68fb25fa3f
commit e7959c280c
No known key found for this signature in database
GPG key ID: 4059CB85CA7E8F19
4 changed files with 85 additions and 5 deletions

View file

@ -659,14 +659,28 @@ static CURLcode smtp_perform_rcpt_to(struct connectdata *conn)
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
struct SMTP *smtp = data->req.protop;
char *address = NULL;
struct hostname host = { NULL, NULL, NULL, NULL };
/* Parse the recipient mailbox into the local address and host name parts,
converting the host name to an IDN A-label if necessary */
result = smtp_parse_address(conn, smtp->rcpt->data,
&address, &host);
if(result)
return result;
/* Send the RCPT TO command */
if(smtp->rcpt->data[0] == '<')
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:%s",
smtp->rcpt->data);
if(host.name)
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:<%s@%s>", address,
host.name);
else
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:<%s>",
smtp->rcpt->data);
/* An invalid mailbox was provided but we'll simply let the server worry
about that and reply with a 501 error */
result = Curl_pp_sendf(&conn->proto.smtpc.pp, "RCPT TO:<%s>", address);
Curl_free_idnconverted_hostname(&host);
free(address);
if(!result)
state(conn, SMTP_RCPT);