Subject: Re: bug#63332: Acknowledgement (28.2.50; pop3.el does not support UTF-8 (RFC 6856))

From: Benjamin Riefenstahl <[email-masked]>
Date: Sat, 06 May 2023 19:26:40 +0200

With bug number and ignore-error*s* instead of ignore-error.

>From 8af24a0d39f5104615cafd45af30fd5765108197 Mon Sep 17 00:00:00 2001
From: Benjamin Riefenstahl <[email-masked]>
Date: Sat, 6 May 2023 19:06:06 +0200
Subject: [PATCH] Support RFC 6856 (bug#63332)

* lisp/net/pop3.el (pop3-open-server): Send "UTF8" when needed.
---
 lisp/net/pop3.el | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/lisp/net/pop3.el b/lisp/net/pop3.el
index d2fdbc3ffff..aacb96dc5ec 100644
--- a/lisp/net/pop3.el
+++ b/lisp/net/pop3.el
@@ -551,13 +551,20 @@ pop3-open-server
 	       (and (string-match "\\bSTLS\\b" capabilities)
 		    "STLS\r\n"))))
       (when result
-	(let ((response (plist-get (cdr result) :greeting)))
+	(let* ((process (car result))
+               (properties (cdr result))
+               (response (plist-get properties :greeting))
+               (capabilities (plist-get properties :capabilities)))
 	  (setq pop3-timestamp
 		(substring response (or (string-search "<" response) 0)
-			   (+ 1 (or (string-search ">" response) -1)))))
-	(set-process-query-on-exit-flag (car result) nil)
-	(erase-buffer)
-	(car result)))))
+			   (+ 1 (or (string-search ">" response) -1))))
+	  (set-process-query-on-exit-flag process nil)
+	  (erase-buffer)
+          ;; Support RFC 6856.
+          (when (string-match "\\bUTF8\\b" capabilities)
+            (pop3-send-command process "UTF8")
+            (ignore-errors (pop3-read-response process)))
+	  process)))))
 
 ;; Support functions
 
-- 
2.30.2