}
private static readonly char[] s_headerValueSplitChars = new char[] { '\r', '\n', ' ' };
- private static readonly char[] s_questionMarkSplitChars = new char[] { '?' };
internal static string DecodeHeaderValue(string? value)
{
//the third is the unicode encoding type, and the fourth is encoded message itself. '?' is not valid inside of
//an encoded string other than as a separator for these five parts.
//If this check fails, the string is either not encoded or cannot be decoded by this method
- string[] subStrings = foldedSubString.Split(s_questionMarkSplitChars);
+ string[] subStrings = foldedSubString.Split('?');
if ((subStrings.Length != 5 || subStrings[0] != "=" || subStrings[4] != "="))
{
return value;
{
internal static partial class StringParsingHelpers
{
- private static readonly string[] s_newLineSeparator = new string[] { Environment.NewLine }; // Used for string splitting
-
internal static int ParseNumSocketConnections(string filePath, string protocolName)
{
// Parse the number of active connections out of /proc/net/sockstat
if (tcp4ConnectionsFile != null)
{
string tcp4FileContents = ReadAllText(tcp4ConnectionsFile);
- v4connections = tcp4FileContents.Split(s_newLineSeparator, StringSplitOptions.RemoveEmptyEntries);
+ v4connections = tcp4FileContents.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
}
else
{
if (tcp6ConnectionsFile != null)
{
string tcp6FileContents = ReadAllText(tcp6ConnectionsFile);
- v6connections = tcp6FileContents.Split(s_newLineSeparator, StringSplitOptions.RemoveEmptyEntries);
+ v6connections = tcp6FileContents.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
}
else
{
if (tcp4ConnectionsFile != null)
{
string tcp4FileContents = ReadAllText(tcp4ConnectionsFile);
- v4connections = tcp4FileContents.Split(s_newLineSeparator, StringSplitOptions.RemoveEmptyEntries);
+ v4connections = tcp4FileContents.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
}
else
{
if (tcp6ConnectionsFile != null)
{
string tcp6FileContents = ReadAllText(tcp6ConnectionsFile);
- v6connections = tcp6FileContents.Split(s_newLineSeparator, StringSplitOptions.RemoveEmptyEntries);
+ v6connections = tcp6FileContents.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
}
else
{
if (udp4File != null)
{
string udp4FileContents = ReadAllText(udp4File);
- v4connections = udp4FileContents.Split(s_newLineSeparator, StringSplitOptions.RemoveEmptyEntries);
+ v4connections = udp4FileContents.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
}
else
{
if (udp6File != null)
{
string udp6FileContents = ReadAllText(udp6File);
- v6connections = udp6FileContents.Split(s_newLineSeparator, StringSplitOptions.RemoveEmptyEntries);
+ v6connections = udp6FileContents.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
}
else
{