You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When reading csv data which causes a TypeConverterException, the Text and RawRecord values are contained in the exception. If ExceptionMessagesContainRawData is set to false, this replaces the Text value but the exception still contains the value of the RawRecord in the property Context.Parser.RawRecord
To Reproduce
`StringBuilder sb = new();
sb.AppendLine("Name,Value");
sb.AppendLine($"Sensitive Name,Sensitive Value");
byte[] byteArray = Encoding.UTF8.GetBytes(sb.ToString());
using MemoryStream memoryStream = new(byteArray);
using StreamReader sr = new(memoryStream);
var reader = new CsvHelper.CsvReader(sr, new CsvConfiguration(System.Globalization.CultureInfo.InvariantCulture) { ExceptionMessagesContainRawData = false });
try
{
reader.Read();
var record = reader.GetRecord();
}
catch(TypeConverterException ex)
{
Console.WriteLine(ex.Context?.Parser?.RawRecord); // RawRecord still contains the sensitive data
}`
Expected behavior
The RawRecord in the exception should contain replacement text when ExceptionMessagesContainRawData = false
The text was updated successfully, but these errors were encountered:
Describe the bug
When reading csv data which causes a TypeConverterException, the Text and RawRecord values are contained in the exception. If ExceptionMessagesContainRawData is set to false, this replaces the Text value but the exception still contains the value of the RawRecord in the property Context.Parser.RawRecord
To Reproduce
`StringBuilder sb = new();
sb.AppendLine("Name,Value");
sb.AppendLine($"Sensitive Name,Sensitive Value");
byte[] byteArray = Encoding.UTF8.GetBytes(sb.ToString());
using MemoryStream memoryStream = new(byteArray);
using StreamReader sr = new(memoryStream);
var reader = new CsvHelper.CsvReader(sr, new CsvConfiguration(System.Globalization.CultureInfo.InvariantCulture) { ExceptionMessagesContainRawData = false });
try
{
reader.Read();
var record = reader.GetRecord();
}
catch(TypeConverterException ex)
{
Console.WriteLine(ex.Context?.Parser?.RawRecord); // RawRecord still contains the sensitive data
}`
Expected behavior
The RawRecord in the exception should contain replacement text when ExceptionMessagesContainRawData = false
The text was updated successfully, but these errors were encountered: