Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null pointer exception when invalid metadata from btcpay #352

Merged
merged 3 commits into from
Dec 8, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions src/Pages/Withdrawals.razor
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@
TemplatePsbtString="@_templatePsbtString"
ApproveRequestDelegate="async () => await ApproveRequestDelegate()"/>

<CancelOrRejectPopup

Check warning on line 391 in src/Pages/Withdrawals.razor

View workflow job for this annotation

GitHub Actions / build-and-test

Component 'CancelOrRejectPopup' expects a value for the parameter 'Reason', but a value may not have been provided.
@ref="@_rejectCancelModalRef"
Title='@("Wallet withdrawal:" + _selectedRequest?.Id)'
Validator="@RejectReasonValidator"
Expand Down Expand Up @@ -586,23 +586,15 @@
{
if (walletWithdrawalRequest.RequestMetadata != null)
Jossec101 marked this conversation as resolved.
Show resolved Hide resolved
{
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;
}
}

Jossec101 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading