mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-25 06:13:50 +00:00
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:
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);
|
||||
}
|
||||
Reference in new issue
Block a user