commit:     60e3cac577c73056221a99bcaeded29a0bde2264
Author:     Yixun Lan <dlan <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 26 22:08:00 2025 +0000
Commit:     Yixun Lan <dlan <AT> gentoo <DOT> org>
CommitDate: Fri Sep 26 22:13:08 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=60e3cac5

mail-mta/msmtp: Fix tests failure with USE=-nls

Fix header encoding when building with --disable-nls.

Closes: https://bugs.gentoo.org/963426
Link: https://github.com/marlam/msmtp/issues/203
Thanks-to: Holger Hoffstätte <holger <AT> applied-asynchrony.com>
Signed-off-by: Yixun Lan <dlan <AT> gentoo.org>

 .../msmtp/files/msmtp-1.8.31-fix-disable-nls.patch | 30 ++++++++++++++++++++++
 ...{msmtp-1.8.31.ebuild => msmtp-1.8.31-r1.ebuild} |  2 ++
 2 files changed, 32 insertions(+)

diff --git a/mail-mta/msmtp/files/msmtp-1.8.31-fix-disable-nls.patch 
b/mail-mta/msmtp/files/msmtp-1.8.31-fix-disable-nls.patch
new file mode 100644
index 000000000000..c52c42af9d0d
--- /dev/null
+++ b/mail-mta/msmtp/files/msmtp-1.8.31-fix-disable-nls.patch
@@ -0,0 +1,30 @@
+Subject: [PATCH] Fix header encoding when building with --disable-nls.
+
+With disabled NLS, msmtp now assumes that UTF-8 is the current codeset,
+which is a better guess than ASCII, which is what nl_langinfo() returns.
+
+This fixes github issue #203.
+---
+URL: 
https://github.com/marlam/msmtp/commit/c6baa5b39e811ea4459a35ae0de88163f65bf8a2
+---
+ src/tools.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/src/tools.c b/src/tools.c
+index b65b4c5..9d78fc8 100644
+--- a/src/tools.c
++++ b/src/tools.c
+@@ -1012,7 +1012,13 @@ char *encode_for_header(const char *s)
+         size_t b64_s_len = BASE64_LENGTH(s_len);
+         char* encoding =
+ #ifdef HAVE_LANGINFO_H
++            /* With disabled NLS, nl_langinfo() always seems to return
++             * ANSI_X3.4-1968 (i.e. ASCII). We want to assume UTF-8 instead. 
*/
++# ifdef ENABLE_NLS
+                 nl_langinfo(CODESET);
++# else
++                "UTF-8";
++# endif
+ #else
+ # ifdef W32_NATIVE
+                 w32_langinfo_codeset();

diff --git a/mail-mta/msmtp/msmtp-1.8.31.ebuild 
b/mail-mta/msmtp/msmtp-1.8.31-r1.ebuild
similarity index 98%
rename from mail-mta/msmtp/msmtp-1.8.31.ebuild
rename to mail-mta/msmtp/msmtp-1.8.31-r1.ebuild
index 6aac73aaba8e..396e1785fbdf 100644
--- a/mail-mta/msmtp/msmtp-1.8.31.ebuild
+++ b/mail-mta/msmtp/msmtp-1.8.31-r1.ebuild
@@ -58,6 +58,8 @@ BDEPEND="
 
 DOCS="AUTHORS ChangeLog NEWS README THANKS doc/msmtprc*"
 
+PATCHES=( "${FILESDIR}/${P}-fix-disable-nls.patch" )
+
 src_prepare() {
        # Use default Gentoo location for mail aliases
        sed 's:/etc/aliases:/etc/mail/aliases:' \

Reply via email to