Files
jobtrackingapp/JobTrackerApi/Services/CsvCellSafety.cs
cesnimda 0954876295 fix(security): enforce audited account, network and resource boundaries
Implement B01-B06 with regression coverage and retained validation evidence. Preserve the production ingress preflight; F04 runtime verification remains open.
2026-09-09 18:21:47 +02:00

22 lines
753 B
C#

using System.Globalization;
using System.Text;
namespace JobTrackerApi.Services;
public static class CsvCellSafety
{
// Apply to text before CSV quoting, never to stored data or typed numbers/dates.
// Prefix before (not instead of) whitespace/controls; an existing apostrophe is safe.
public static string SpreadsheetText(string? value)
{
if (string.IsNullOrEmpty(value)) return value ?? "";
foreach (var rune in value.EnumerateRunes())
{
if (Rune.IsWhiteSpace(rune) || Rune.IsControl(rune) || Rune.GetUnicodeCategory(rune) == UnicodeCategory.Format)
continue;
return rune.Value is '=' or '+' or '-' or '@' ? "'" + value : value;
}
return value;
}
}