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

@@ -0,0 +1,28 @@
using System.Text.Json;
using System.Text.Json.Serialization;
namespace AIStudio.Tools.Mail;
/// <summary>
/// Stores the password encoding of a mailbox by its name, e.g., "windows-1252".
/// </summary>
/// <remarks>
/// A name this version does not know is read as it is and written back unchanged, cf.
/// MailboxPasswordEncoding.IsKnown. Anything else than a name, e.g., a number written by hand, is no
/// encoding at all: the mailbox then signs in nowhere, but the other settings are read as usual.
/// </remarks>
public sealed class MailboxPasswordEncodingJsonConverter : JsonConverter<MailboxPasswordEncoding>
{
/// <inheritdoc />
public override MailboxPasswordEncoding Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType is JsonTokenType.String)
return MailboxPasswordEncoding.FromName(reader.GetString());
reader.Skip();
return MailboxPasswordEncoding.FromName(null);
}
/// <inheritdoc />
public override void Write(Utf8JsonWriter writer, MailboxPasswordEncoding value, JsonSerializerOptions options) => writer.WriteStringValue(value.Name);
}