From 72315c8c4c0b3b0748a0e2a6b2edf82fda84ecec Mon Sep 17 00:00:00 2001 From: Sam Varshavchik Date: Thu, 29 Aug 2024 21:10:13 -0400 Subject: [PATCH] Correctly enable UTF8 on proxied POP3 connections. --- imap/ChangeLog | 7 +++++++ imap/configure.ac | 2 +- imap/pop3login.c | 24 +++++++++++++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/imap/ChangeLog b/imap/ChangeLog index f6fb39ed..a431ef4b 100644 --- a/imap/ChangeLog +++ b/imap/ChangeLog @@ -1,3 +1,10 @@ +5.2.10 + +2024-08-29 Sam Varshavchik + + * pop3login.c (login_pop3): Fix a problem when proxying UTF8 POP3 + connections. + 5.2.9 2024-08-05 Sam Varshavchik diff --git a/imap/configure.ac b/imap/configure.ac index 34ee7342..b7587998 100644 --- a/imap/configure.ac +++ b/imap/configure.ac @@ -4,7 +4,7 @@ dnl dnl Copyright 1998 - 2022 Double Precision, Inc. See COPYING for dnl distribution information. -AC_INIT([courier-imap],[5.2.9],[courier-users@lists.sourceforge.net]) +AC_INIT([courier-imap],[5.2.10],[courier-users@lists.sourceforge.net]) >confdefs.h # Kill PACKAGE_ macros diff --git a/imap/pop3login.c b/imap/pop3login.c index 58830838..13797927 100644 --- a/imap/pop3login.c +++ b/imap/pop3login.c @@ -1,5 +1,5 @@ /* -** Copyright 1998 - 2021 Double Precision, Inc. +** Copyright 1998 - 2024 Double Precision, Inc. ** See COPYING for distribution information. */ @@ -565,6 +565,28 @@ static int login_pop3(int fd, const char *hostname, void *void_arg) return -1; } + if (utf8_enabled) + { + if (proxy_write(fd, hostname, "UTF8\r\n", 6)) + { + return -1; + } + + if (proxy_readline(fd, &pb, linebuf, sizeof(linebuf), 1) < 0) + { + return -1; + } + + DPRINTF("%s: %s", hostname, linebuf); + + if (linebuf[0] != '+') + { + fprintf(stderr, "WARN: UTF8 rejected by %s\n", + hostname); + return -1; + } + } + cmd=malloc(strlen(ppi->uid) + strlen(ppi->pwd)+100); /* Should be enough */