Skip to content

Commit

Permalink
Sanitize email when retrieving emails for emailbox (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
lanedirt committed Dec 24, 2024
1 parent 80cc72e commit 3872678
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/AliasVault.Api/Controllers/Email/EmailBoxController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ public async Task<IActionResult> GetEmailBox(string to)
return Unauthorized("Not authenticated.");
}

var sanitizedEmail = to.Trim().ToLower();

// See if this user has a valid claim to the email address.
var emailClaim = await context.UserEmailClaims
.FirstOrDefaultAsync(x => x.Address == to);
.FirstOrDefaultAsync(x => x.Address == sanitizedEmail);

if (emailClaim is null)
{
return BadRequest(new ApiErrorResponse
{
Message = "No claim exists for this email address.",
Code = "CLAIM_DOES_NOT_EXIST",
Details = new { ProvidedEmail = to },
Details = new { ProvidedEmail = sanitizedEmail },
StatusCode = StatusCodes.Status400BadRequest,
Timestamp = DateTime.UtcNow,
});
Expand Down

0 comments on commit 3872678

Please sign in to comment.