diff options
author | Steve Holme <steve_holme@hotmail.com> | 2020-02-08 00:14:57 +0000 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2020-02-26 11:02:38 +0000 |
commit | e7959c280c0361d2e448776d9ea11305e2f026bc (patch) | |
tree | 71cf32e9bd8e63ffeb62474a48908c741b9b55ba /lib/smtp.c | |
parent | 68fb25fa3fcff62dda71d2c67894eedf93291e05 (diff) | |
download | curl-e7959c280c0361d2e448776d9ea11305e2f026bc.tar.gz |
smtp: Support UTF-8 based host names in the RCPT TO command
Diffstat (limited to 'lib/smtp.c')
-rw-r--r-- | lib/smtp.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/smtp.c b/lib/smtp.c index 18c45afbe..1718cc2db 100644 --- a/lib/smtp.c +++ b/lib/smtp.c @@ -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); |