mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-03 17:36:59 +01:00
Always using quotes for CSV export
This commit is contained in:
parent
a4bec83ecc
commit
7b47b96252
2 changed files with 6 additions and 11 deletions
|
@ -1669,7 +1669,7 @@ donation:
|
||||||
Currency = "USD",
|
Currency = "USD",
|
||||||
PosData = "posData",
|
PosData = "posData",
|
||||||
OrderId = "orderId",
|
OrderId = "orderId",
|
||||||
ItemDesc = "Some description",
|
ItemDesc = "Some \", description",
|
||||||
FullNotifications = true
|
FullNotifications = true
|
||||||
}, Facade.Merchant);
|
}, Facade.Merchant);
|
||||||
|
|
||||||
|
@ -1683,9 +1683,9 @@ donation:
|
||||||
var exportResultPaid = user.GetController<InvoiceController>().Export("csv").GetAwaiter().GetResult();
|
var exportResultPaid = user.GetController<InvoiceController>().Export("csv").GetAwaiter().GetResult();
|
||||||
var paidresult = Assert.IsType<ContentResult>(exportResultPaid);
|
var paidresult = Assert.IsType<ContentResult>(exportResultPaid);
|
||||||
Assert.Equal("application/csv", paidresult.ContentType);
|
Assert.Equal("application/csv", paidresult.ContentType);
|
||||||
Assert.Contains("BTC,5000.0,BTCLike,", paidresult.Content);
|
Assert.Contains("\"BTC\",\"5000.0\",\"BTCLike\",", paidresult.Content);
|
||||||
Assert.Contains($",0.10020000 BTC,0.10009990 BTC,0.00000000 BTC,{invoice.Id},", paidresult.Content);
|
Assert.Contains($",\"0.10020000 BTC\",\"0.10009990 BTC\",\"0.00000000 BTC\",\"{invoice.Id}\",", paidresult.Content);
|
||||||
Assert.Contains(",new,,Some description,500.0,USD", paidresult.Content);
|
Assert.Contains(",\"new\",\"\",\"Some ``, description\",\"500.0\",\"USD\"", paidresult.Content);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -23,11 +23,9 @@ namespace BTCPayServer.Services.Invoices.Export
|
||||||
public string NewlineReplacement { get; set; } = ((char)0x254).ToString(CultureInfo.InvariantCulture);
|
public string NewlineReplacement { get; set; } = ((char)0x254).ToString(CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
public char Separator { get; set; } = ',';
|
public char Separator { get; set; } = ',';
|
||||||
public string Replacement { get; set; } = ((char)0x255).ToString(CultureInfo.InvariantCulture);
|
|
||||||
|
|
||||||
public string RowNumberColumnTitle { get; set; } = "RowNumber";
|
public string RowNumberColumnTitle { get; set; } = "RowNumber";
|
||||||
public bool UseLineNumbers { get; set; } = false;
|
public bool UseLineNumbers { get; set; } = false;
|
||||||
public bool UseTextQualifier { get; set; } = false;
|
|
||||||
public bool UseEofLiteral { get; set; } = false;
|
public bool UseEofLiteral { get; set; } = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -83,13 +81,10 @@ namespace BTCPayServer.Services.Invoices.Export
|
||||||
var raw = p.GetValue(item);
|
var raw = p.GetValue(item);
|
||||||
var value = raw == null ? "" :
|
var value = raw == null ? "" :
|
||||||
raw.ToString()
|
raw.ToString()
|
||||||
.Replace(Separator.ToString(CultureInfo.InvariantCulture), Replacement, StringComparison.OrdinalIgnoreCase)
|
.Replace("\"", "``", StringComparison.OrdinalIgnoreCase)
|
||||||
.Replace(Environment.NewLine, NewlineReplacement, StringComparison.OrdinalIgnoreCase);
|
.Replace(Environment.NewLine, NewlineReplacement, StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
if (UseTextQualifier)
|
|
||||||
{
|
|
||||||
value = String.Format(CultureInfo.InvariantCulture, "\"{0}\"", value);
|
value = String.Format(CultureInfo.InvariantCulture, "\"{0}\"", value);
|
||||||
}
|
|
||||||
|
|
||||||
values.Add(value);
|
values.Add(value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue