]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap-login: Move forward_fields updating code to login-common
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 23 Mar 2017 18:16:44 +0000 (20:16 +0200)
committerGitLab <gitlab@git.dovecot.net>
Fri, 24 Mar 2017 11:03:56 +0000 (13:03 +0200)
This allows using the new client_add_forward_field() in e.g. plugins.

src/imap-login/imap-login-client.c
src/login-common/client-common.c
src/login-common/client-common.h

index 79f1c1a284af8d46b8e9490108e05ef03ad8963e..326840d491bc0715bf2b27d24c94c1077308baa5 100644 (file)
@@ -7,7 +7,6 @@
 #include "ostream.h"
 #include "safe-memset.h"
 #include "str.h"
-#include "strescape.h"
 #include "imap-parser.h"
 #include "imap-id.h"
 #include "imap-resp-code.h"
@@ -202,15 +201,7 @@ client_update_info(struct imap_client *client,
                }
        } else if (strncasecmp(key, "x-forward-", 10) == 0) {
                /* handle extra field */
-               if (client->common.forward_fields == NULL)
-                       client->common.forward_fields = str_new(client->common.preproxy_pool, 32);
-               else
-                       str_append_c(client->common.forward_fields, '\t');
-               /* prefixing is done by auth process */
-               str_append_tabescaped(client->common.forward_fields,
-                                     key+10);
-               str_append_c(client->common.forward_fields, '=');
-               str_append_tabescaped(client->common.forward_fields, value);
+               client_add_forward_field(&client->common, key+10, value);
        } else {
                return FALSE;
        }
index 7bb23831df1286b4b49b273c64ddf91582750df4..2b6fa76c60bf758238222a2768ddf2d2e40c4b5c 100644 (file)
@@ -11,6 +11,7 @@
 #include "hook-build.h"
 #include "buffer.h"
 #include "str.h"
+#include "strescape.h"
 #include "base64.h"
 #include "str-sanitize.h"
 #include "safe-memset.h"
@@ -486,6 +487,19 @@ unsigned int clients_get_count(void)
        return clients_count;
 }
 
+void client_add_forward_field(struct client *client, const char *key,
+                             const char *value)
+{
+       if (client->forward_fields == NULL)
+               client->forward_fields = str_new(client->preproxy_pool, 32);
+       else
+               str_append_c(client->forward_fields, '\t');
+       /* prefixing is done by auth process */
+       str_append_tabescaped(client->forward_fields, key);
+       str_append_c(client->forward_fields, '=');
+       str_append_tabescaped(client->forward_fields, value);
+}
+
 const char *client_get_session_id(struct client *client)
 {
        buffer_t *buf, *base64_buf;
index 7a92e9655f64851bdc27684608adb94735077398..f3d188e7a40ae4b3d785a0a9873255c9df06a28c 100644 (file)
@@ -242,6 +242,8 @@ void client_cmd_starttls(struct client *client);
 
 unsigned int clients_get_count(void) ATTR_PURE;
 
+void client_add_forward_field(struct client *client, const char *key,
+                             const char *value);
 void client_set_title(struct client *client);
 void client_log(struct client *client, const char *msg);
 void client_log_err(struct client *client, const char *msg);