Skip to content

Commit

Permalink
Null pointer exception when invalid metadata from btcpay (#352)
Browse files Browse the repository at this point in the history
Co-authored-by: José A.P <[email protected]>
  • Loading branch information
RodriFS and Jossec101 authored Dec 8, 2023
1 parent 96dcd2b commit bd6d840
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/Pages/Withdrawals.razor
Original file line number Diff line number Diff line change
Expand Up @@ -586,23 +586,15 @@
{
if (walletWithdrawalRequest.RequestMetadata != null)
{
try
var requestMetadata = JsonConvert.DeserializeObject<Dictionary<string, string>>(walletWithdrawalRequest.RequestMetadata);
if (requestMetadata != null && requestMetadata.TryGetValue("userName", out var userName))
{
var requestMetadata = JsonConvert.DeserializeObject<Dictionary<string, string>>(walletWithdrawalRequest.RequestMetadata);

if (requestMetadata.TryGetValue("userName", out var userName))
if (ValidationHelper.IsValidEmail(userName))
{
if (ValidationHelper.IsValidEmail(userName))
{
int atIndex = userName.IndexOf('@');
return atIndex >= 0 ? userName.Substring(0, atIndex) : userName;
}
return userName;
int atIndex = userName.IndexOf('@');
return atIndex >= 0 ? userName.Substring(0, atIndex) : userName;
}
}
catch (JsonReaderException ex)
{
Console.WriteLine("Invalid JSON: " + ex.Message);
return userName;
}
}

Expand Down

0 comments on commit bd6d840

Please sign in to comment.