Skip to content

Commit

Permalink
Test IDN with NLS on GH
Browse files Browse the repository at this point in the history
  • Loading branch information
mlt committed Sep 24, 2024
1 parent 692a623 commit c1bfab0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,54 @@ jobs:
with:
name: msmtp-libressl
path: D:\a\msmtp\tmp\
nls:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Install build dependencies
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
install: >-
mingw-w64-ucrt-x86_64-gcc
pkgconf
automake
autoconf
make
texinfo
- name: Build
run: |
autoreconf -i
mkdir nls && cd nls
# The only function from libwinpthread is clock_gettime()
../configure --with-tls=sspi LDFLAGS=-Wl,-Bstatic,-lwinpthread CFLAGS=-DFIXME1
make
cd .. && mkdir norm && cd norm
../configure --with-tls=sspi LDFLAGS=-Wl,-Bstatic,-lwinpthread
make
- name: Set locale
shell: pwsh
run: |
Set-WinSystemLocale -SystemLocale ru-RU
- name: Test IDN fixme
continue-on-error: true
run: |
nls/src/msmtp --debug --serverinfo --tls --host=mx3.почта.рус --port=1234 > output.log 2>&1 || true
cat output.log | iconv -f cp1251 -t utf-8
grep -q 'connection refused' output.log && echo 🎉 The host was found successfully but the connection was refused.
- name: Test IDN fixme 2
continue-on-error: true
run: |
nls/src/msmtp --debug --serverinfo --tls --host=mx3.почта.рус --port=1234
- name: Test IDN norm 2
continue-on-error: true
run: |
norm/src/msmtp --debug --serverinfo --tls --host=mx3.почта.рус --port=1234
native:
runs-on: windows-latest
defaults:
Expand Down
5 changes: 2 additions & 3 deletions src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,22 +761,21 @@ int net_open_socket(
size_t conv;
WCHAR hostname_wide[NI_MAXHOST];
/* We rely on a proper setlocale earlier that was NOT "C" as set default by MS C runtime. */
#ifdef ENABLE_NLS
#if defined(ENABLE_NLS) && defined(FIXME1)
/* FIXME: Something messes up locale (at least on MSYS2/UCRT64) and setlocale(LC_ALL, "") won't fix it.
* The commented code below is the way to get proper console output for hostname.
* Otherwise let's make sure we get proper IDN conversion and that is it. */
/*
char locale_name[LOCALE_NAME_MAX_LENGTH * sizeof(WCHAR)];
GetSystemDefaultLocaleName((LPWSTR)locale_name, LOCALE_NAME_MAX_LENGTH);
size_t len = wcsnlen_s((LPWSTR)locale_name, LOCALE_NAME_MAX_LENGTH);
for (int i = 1; i <= len; ++i)
locale_name[i] = locale_name[i * 2];
setlocale(LC_ALL, locale_name);
*/
_locale_t locale = _create_locale(LC_ALL, "");
errno_t err = _mbstowcs_s_l(&conv, hostname_wide, ARRAYSIZE(hostname_wide), hostname, _TRUNCATE, locale);
_free_locale(locale);
#else
setlocale(LC_ALL, "");
errno_t err = mbstowcs_s(&conv, hostname_wide, ARRAYSIZE(hostname_wide), hostname, _TRUNCATE);
#endif
if (!err)
Expand Down

0 comments on commit c1bfab0

Please sign in to comment.