Fixed signing in to mailboxes with characters beyond ASCII in the username or password (#1224)

Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
Peer HogeterpandThorsten Sommer authored and GitHub committed 2026-11-24 15:53:19 +01:00
1 parent f6a4348820
commit c72a1948b3
27 files changed
+1052 -30

No files matched your search

@@ -58,6 +58,18 @@ public sealed record DataMailboxProvider : ILivePluginContent
/// </summary>
public string HelpUrl { get; private init; } = string.Empty;
/// <summary>
/// The encoding the mail server expects for a username or a password with characters beyond
/// ASCII, e.g., "windows-1252". Null when the organization did not say.
/// </summary>
/// <remarks>
/// Depending on its configuration, a mail server may expect another encoding than UTF-8, e.g.,
/// Microsoft Exchange the code page of its Windows system. The organization knows which one, so
/// its users spend no failed sign-in on finding out: every mailbox on this server signs in with
/// it, cf. MailServerPolicy.GetPasswordEncoding.
/// </remarks>
public MailboxPasswordEncoding? PasswordEncoding { get; private init; }
/// <summary>
/// Reads a mail server from an entry of the table MAILBOX_PROVIDERS.
/// </summary>
@@ -131,6 +143,19 @@ public sealed record DataMailboxProvider : ILivePluginContent
helpUrl = helpUri.OriginalString;
}
MailboxPasswordEncoding? passwordEncoding = null;
if (table.TryGetValue("PasswordEncoding", out var passwordEncodingValue))
{
var readPasswordEncoding = passwordEncodingValue.TryRead<string>(out var passwordEncodingText) ? MailboxPasswordEncoding.FromName(passwordEncodingText) : default;
if (!readPasswordEncoding.IsKnown)
{
logger.LogWarning("The configured mailbox provider {ProviderIndex} does not contain a valid PasswordEncoding field. It needs the name of an encoding which keeps ASCII as it is, such as utf-8, windows-1252, or shift_jis.", index);
return false;
}
passwordEncoding = readPasswordEncoding;
}
provider = new DataMailboxProvider
{
Id = id.ToString(),
@@ -141,6 +166,7 @@ public sealed record DataMailboxProvider : ILivePluginContent
TransportSecurity = transportSecurity,
UsernameHint = usernameHint,
HelpUrl = helpUrl,
PasswordEncoding = passwordEncoding,
};
return true;