summaryrefslogtreecommitdiff
path: root/net-mail/fdm/files/fdm-2.2-pop3-utf8.patch
blob: 71cc08197ad7fc5ab41b36949cdafb952a91535b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
https://github.com/nicm/fdm/commit/0918b78a82a789d63cebe44b7662f0a8dc603000

From 0918b78a82a789d63cebe44b7662f0a8dc603000 Mon Sep 17 00:00:00 2001
From: Nicholas Marriott <nicholas.marriott@gmail.com>
Date: Mon, 4 Sep 2023 09:03:47 +0100
Subject: [PATCH] Send UTF8 command to POP3 server (ignore the response),
 because some servers don't like UTF-8 without it.

---
 pop3-common.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/pop3-common.c b/pop3-common.c
index 0724887..e038172 100644
--- a/pop3-common.c
+++ b/pop3-common.c
@@ -54,6 +54,7 @@ int	pop3_invalid(struct account *, const char *);
 int	pop3_state_connect(struct account *, struct fetch_ctx *);
 int	pop3_state_starttls(struct account *, struct fetch_ctx *);
 int	pop3_state_connected(struct account *, struct fetch_ctx *);
+int	pop3_state_utf8(struct account *, struct fetch_ctx *);
 int	pop3_state_user(struct account *, struct fetch_ctx *);
 int	pop3_state_cache1(struct account *, struct fetch_ctx *);
 int	pop3_state_cache2(struct account *, struct fetch_ctx *);
@@ -436,6 +437,24 @@ pop3_state_connected(struct account *a, struct fetch_ctx *fctx)
 		}
 	}
 
+	if (pop3_putln(a, "UTF8") != 0)
+		return (FETCH_ERROR);
+	fctx->state = pop3_state_utf8;
+	return (FETCH_BLOCK);
+}
+
+/* UTF8 state. */
+int
+pop3_state_utf8(struct account *a, struct fetch_ctx *fctx)
+{
+	struct fetch_pop3_data	*data = a->data;
+	char			*line;
+
+	if (pop3_getln(a, fctx, &line) != 0)
+		return (FETCH_ERROR);
+	if (line == NULL)
+		return (FETCH_BLOCK);
+
 	if (pop3_putln(a, "USER %s", data->user) != 0)
 		return (FETCH_ERROR);
 	fctx->state = pop3_state_user;