Make sure tags does not contains ','

This commit is contained in:
nicolas.dorier
2019-08-03 22:06:14 +09:00
parent 23d546c559
commit 756b6e9692
2 changed files with 3 additions and 1 deletions

View File

@@ -130,7 +130,7 @@ namespace BTCPayServer.Controllers
var walletTransactionsInfo = await walletTransactionsInfoAsync; var walletTransactionsInfo = await walletTransactionsInfoAsync;
if (addlabel != null) if (addlabel != null)
{ {
addlabel = addlabel.Trim().ToLowerInvariant().Truncate(MaxLabelSize); addlabel = addlabel.Trim().ToLowerInvariant().Replace(',',' ').Truncate(MaxLabelSize);
var labels = walletBlobInfo.GetLabels(); var labels = walletBlobInfo.GetLabels();
if (!walletTransactionsInfo.TryGetValue(transactionId, out var walletTransactionInfo)) if (!walletTransactionsInfo.TryGetValue(transactionId, out var walletTransactionInfo))
{ {

View File

@@ -35,6 +35,8 @@ namespace BTCPayServer.Data
Blob = Array.Empty<byte>(); Blob = Array.Empty<byte>();
return; return;
} }
if (blobInfo.Labels.Any(l => l.Contains(',', StringComparison.OrdinalIgnoreCase)))
throw new ArgumentException(paramName: nameof(blobInfo), message: "Labels must not contains ','");
Labels = String.Join(',', blobInfo.Labels); Labels = String.Join(',', blobInfo.Labels);
Blob = ZipUtils.Zip(JsonConvert.SerializeObject(blobInfo)); Blob = ZipUtils.Zip(JsonConvert.SerializeObject(blobInfo));
} }