Forge
csharpdeeb25a2
1using CascadeIDE.Contracts;
2
3namespace CascadeIDE.Features.Terminal.DataAcquisition;
4
5[IoBoundary]
6internal static class IntegratedShellStreamSanitizer
7{
8 public static byte[] SanitizeShellOutput(ReadOnlySpan<byte> data, ref bool leadingBomStripped)
9 {
10 if (data.IsEmpty)
11 return [];
12
13 if (!leadingBomStripped)
14 {
15 data = StripLeadingUtf8Bom(data);
16 leadingBomStripped = true;
17 }
18
19 return data.ToArray();
20 }
21
22 public static ReadOnlySpan<byte> StripLeadingUtf8Bom(ReadOnlySpan<byte> data)
23 {
24 if (data.Length >= 3 && data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF)
25 return data[3..];
26
27 return data;
28 }
29}
30
View only · write via MCP/CIDE