]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-client - Perform the LF -> CRLF conversion for the message data in...
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 9 Feb 2019 12:55:22 +0000 (13:55 +0100)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Fri, 28 Jun 2019 07:09:31 +0000 (10:09 +0300)
Before, it was performed in the DATA/BDAT command code, which makes it very
difficult to extract post-conversion size statistics.

src/lib-smtp/smtp-client-command.c
src/lib-smtp/smtp-client-command.h
src/lib-smtp/smtp-client-transaction.c

index 2ed1b43c20eff0ffd39eef5280939b1528bebf2e..7803ab5726a096efff55b826d7af0ae8dcc9f986 100644 (file)
@@ -6,7 +6,6 @@
 #include "str.h"
 #include "llist.h"
 #include "istream.h"
-#include "istream-crlf.h"
 #include "ostream.h"
 #include "ostream-dot.h"
 #include "smtp-common.h"
@@ -1457,11 +1456,11 @@ smtp_client_command_data_submit_after(
        /* capture abort event with our context */
        smtp_client_command_set_abort_callback(cmd, _cmd_data_abort_cb, ctx);
 
+       ctx->data = data;
+       i_stream_ref(data);
+
        if ((conn->caps.standard & SMTP_CAPABILITY_CHUNKING) == 0) {
                /* DATA */
-               ctx->data = data;
-               i_stream_ref(data);
-
                p_array_init(&ctx->cmds, ctx->pool, 1);
 
                /* Data stream is sent in one go in the second stage. Since the data
@@ -1479,8 +1478,6 @@ smtp_client_command_data_submit_after(
 
        } else {
                /* BDAT */
-               ctx->data = data = i_stream_create_crlf(data);
-
                p_array_init(&ctx->cmds, ctx->pool,
                        conn->set.max_data_chunk_pipeline);
 
index a1d95400ba0b5d84d9cb3fa8e5eb943bf57f291b..e723bbb7810ae4aa0633a48e6055637fea8d1c0f 100644 (file)
@@ -233,7 +233,8 @@ smtp_client_command_rcpt_submit(
                (smtp_client_command_callback_t *)callback, context)
 
 /* Send message data using DATA or BDAT (preferred if supported).
-   This handles the DATA 354 response implicitly.
+   This handles the DATA 354 response implicitly. Making sure that the data has
+   CRLF line endings consistently is the responsibility of the caller.
  */
 struct smtp_client_command *
 smtp_client_command_data_submit_after(
index 36ab444580fdc1c958731c2674f435ca604d935e..58ade75e475c678c43154fba49df3bbeda541391 100644 (file)
@@ -5,6 +5,7 @@
 #include "ioloop.h"
 #include "net.h"
 #include "istream.h"
+#include "istream-crlf.h"
 #include "ostream.h"
 #include "str.h"
 #include "dns-lookup.h"
@@ -1204,8 +1205,7 @@ void smtp_client_transaction_send(
        trans->data_provided = TRUE;
 
        i_assert(trans->data_input == NULL);
-       trans->data_input = data_input;
-       i_stream_ref(data_input);
+       trans->data_input = i_stream_create_crlf(data_input);
 
        trans->data_callback = data_callback;
        trans->data_context = data_context;