Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Prevent error when attempting to encrypt/decrypt empty string (#217)

Leendert de Borst9b250bf83f17
diff --git a/src/AliasVault.Api/Controllers/Email/EmailBoxController.cs b/src/AliasVault.Api/Controllers/Email/EmailBoxController.cs
index 0aefad46a..9ff1a2662 100644
--- a/src/AliasVault.Api/Controllers/Email/EmailBoxController.cs
+++ b/src/AliasVault.Api/Controllers/Email/EmailBoxController.cs
@@ -77,6 +77,7 @@ public class EmailBoxController(IDbContextFactory<AliasServerDbContext> dbContex
{
Id = x.Id,
Subject = x.Subject,
+ FromDisplay = x.From,
FromDomain = x.FromDomain,
FromLocal = x.FromLocal,
ToDomain = x.ToDomain,
diff --git a/src/AliasVault.Client/Services/JsInteropService.cs b/src/AliasVault.Client/Services/JsInteropService.cs
index 232aa0a80..aa6ba4d9c 100644
--- a/src/AliasVault.Client/Services/JsInteropService.cs
+++ b/src/AliasVault.Client/Services/JsInteropService.cs
@@ -23,8 +23,15 @@ public sealed class JsInteropService(IJSRuntime jsRuntime)
/// <param name="plaintext">Plain text to encrypt.</param>
/// <param name="encryptionKey">Encryption key to use.</param>
/// <returns>Encrypted ciphertext.</returns>
- public async Task<string> SymmetricEncrypt(string plaintext, string encryptionKey) =>
- await jsRuntime.InvokeAsync<string>("cryptoInterop.encrypt", plaintext, encryptionKey);
+ public async Task<string> SymmetricEncrypt(string plaintext, string encryptionKey)
+ {
+ if (string.IsNullOrEmpty(plaintext))
+ {
+ return plaintext;
+ }
+
+ return await jsRuntime.InvokeAsync<string>("cryptoInterop.encrypt", plaintext, encryptionKey);
+ }
/// <summary>
/// Symmetrically decrypts a string using the provided encryption key.
@@ -32,8 +39,15 @@ public sealed class JsInteropService(IJSRuntime jsRuntime)
/// <param name="ciphertext">Cipher text to decrypt.</param>
/// <param name="encryptionKey">Encryption key to use.</param>
/// <returns>Encrypted ciphertext.</returns>
- public async Task<string> SymmetricDecrypt(string ciphertext, string encryptionKey) =>
- await jsRuntime.InvokeAsync<string>("cryptoInterop.decrypt", ciphertext, encryptionKey);
+ public async Task<string> SymmetricDecrypt(string ciphertext, string encryptionKey)
+ {
+ if (string.IsNullOrEmpty(ciphertext))
+ {
+ return ciphertext;
+ }
+
+ return await jsRuntime.InvokeAsync<string>("cryptoInterop.decrypt", ciphertext, encryptionKey);
+ }
/// <summary>
/// Downloads a file from a stream.