diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 2b8c78386..93d851446 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -1669,7 +1669,7 @@ donation: Currency = "USD", PosData = "posData", OrderId = "orderId", - ItemDesc = "Some description", + ItemDesc = "Some \", description", FullNotifications = true }, Facade.Merchant); @@ -1683,9 +1683,9 @@ donation: var exportResultPaid = user.GetController().Export("csv").GetAwaiter().GetResult(); var paidresult = Assert.IsType(exportResultPaid); Assert.Equal("application/csv", paidresult.ContentType); - 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(",new,,Some description,500.0,USD", 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(",\"new\",\"\",\"Some ``, description\",\"500.0\",\"USD\"", paidresult.Content); }); /* diff --git a/BTCPayServer/Services/Invoices/Export/CsvSerializer.cs b/BTCPayServer/Services/Invoices/Export/CsvSerializer.cs index a70a3462d..1c64f30ac 100644 --- a/BTCPayServer/Services/Invoices/Export/CsvSerializer.cs +++ b/BTCPayServer/Services/Invoices/Export/CsvSerializer.cs @@ -23,11 +23,9 @@ namespace BTCPayServer.Services.Invoices.Export public string NewlineReplacement { get; set; } = ((char)0x254).ToString(CultureInfo.InvariantCulture); public char Separator { get; set; } = ','; - public string Replacement { get; set; } = ((char)0x255).ToString(CultureInfo.InvariantCulture); public string RowNumberColumnTitle { get; set; } = "RowNumber"; public bool UseLineNumbers { get; set; } = false; - public bool UseTextQualifier { get; set; } = false; public bool UseEofLiteral { get; set; } = false; /// @@ -83,13 +81,10 @@ namespace BTCPayServer.Services.Invoices.Export var raw = p.GetValue(item); var value = raw == null ? "" : raw.ToString() - .Replace(Separator.ToString(CultureInfo.InvariantCulture), Replacement, StringComparison.OrdinalIgnoreCase) + .Replace("\"", "``", 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); }