diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index d5581317ad..2c531e9768 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -44,7 +44,7 @@ namespace OpenSim.Data.MySQL public UserAccountData[] GetUsers(UUID scopeID, string query) { - string[] words = query.Split(new char[] {' '}); + string[] words = query.Split(); bool valid = false; diff --git a/OpenSim/Data/Null/NullUserAccountData.cs b/OpenSim/Data/Null/NullUserAccountData.cs index 6d2e05ac23..b4428da8bb 100644 --- a/OpenSim/Data/Null/NullUserAccountData.cs +++ b/OpenSim/Data/Null/NullUserAccountData.cs @@ -133,7 +133,7 @@ namespace OpenSim.Data.Null // m_log.DebugFormat( // "[NULL USER ACCOUNT DATA]: Called GetUsers with scope [{0}], query [{1}]", scopeID, query); - string[] words = query.Split(new char[] { ' ' }); + string[] words = query.Split(); for (int i = 0; i < words.Length; i++) { diff --git a/OpenSim/Data/PGSQL/PGSQLUserAccountData.cs b/OpenSim/Data/PGSQL/PGSQLUserAccountData.cs index 0a01a5c027..06bad1256b 100644 --- a/OpenSim/Data/PGSQL/PGSQLUserAccountData.cs +++ b/OpenSim/Data/PGSQL/PGSQLUserAccountData.cs @@ -279,7 +279,7 @@ namespace OpenSim.Data.PGSQL public UserAccountData[] GetUsers(UUID scopeID, string query) { - string[] words = query.Split(new char[] { ' ' }); + string[] words = query.Split(); for (int i = 0; i < words.Length; i++) { diff --git a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs index 1b79185953..1a99ab21d2 100644 --- a/OpenSim/Data/SQLite/SQLiteUserAccountData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserAccountData.cs @@ -48,7 +48,7 @@ namespace OpenSim.Data.SQLite public UserAccountData[] GetUsers(UUID scopeID, string query) { - string[] words = query.Split(new char[] {' '}); + string[] words = query.Split(); for (int i = 0 ; i < words.Length ; i++) { diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index 3da2e386ce..80d5993167 100755 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -670,7 +670,7 @@ namespace OpenSim.Framework.Console { if (index % 2 == 0) { - string[] words = unquoted[index].Split(new char[] {' '}); + string[] words = unquoted[index].Split(); bool option = false; foreach (string w in words) diff --git a/OpenSim/Framework/Console/ConsolePluginCommand.cs b/OpenSim/Framework/Console/ConsolePluginCommand.cs index f4d3687450..2bce8b45c3 100755 --- a/OpenSim/Framework/Console/ConsolePluginCommand.cs +++ b/OpenSim/Framework/Console/ConsolePluginCommand.cs @@ -62,7 +62,7 @@ namespace OpenSim.Framework.Console /// the text displayed in "help showme new commands" public ConsolePluginCommand(string command, ConsoleCommand dlg, string help) { - m_cmdText = command.Split(new char[] { ' ' }); + m_cmdText = command.Split(); m_commandDelegate = dlg; m_helpText = help; } diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index e4165d5d94..b8fb1c1597 100755 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -322,7 +322,7 @@ namespace OpenSim.Framework.Console for (i=0 ; i < cmd.Length ; i++) { - if (cmd[i].Contains(" ")) + if (cmd[i].Contains(' ')) cmd[i] = "\"" + cmd[i] + "\""; } return String.Empty; diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 0e9a46e2f3..e89b0ef674 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -536,7 +536,7 @@ namespace OpenSim.Framework if (p.PropertyType.IsArray) { - string[] elements = ((string)map[p.Name]).Split(new char[] { ',' }); + string[] elements = ((string)map[p.Name]).Split(Util.SplitCommaArray); UUID[] uuids = new UUID[elements.Length]; int i = 0; foreach (string e in elements) diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 911194c415..80719dc0b9 100755 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs @@ -511,7 +511,7 @@ namespace OpenSim.Framework config.Set("Location", location); } - string[] locationElements = location.Split(new char[] {','}); + string[] locationElements = location.Split(Util.SplitCommaArray); RegionLocX = Convert.ToUInt32(locationElements[0]); RegionLocY = Convert.ToUInt32(locationElements[1]); diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index be6c97346d..aeb67412d8 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -2443,7 +2443,7 @@ namespace OpenSim.Framework.Servers.HttpServer return; } - string[] splited = methods.Split(new char[] { ',' }); + string[] splited = methods.Split(Util.SplitCommaArray); string method = splited[0]; if (string.IsNullOrWhiteSpace(method)) { diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpListener.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpListener.cs index 1f6471833a..6c2affdd49 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpListener.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpListener.cs @@ -14,7 +14,7 @@ namespace OSHttpServer private readonly X509Certificate m_certificate; private readonly IHttpContextFactory m_contextFactory; private readonly int m_port; - private readonly ManualResetEvent m_shutdownEvent = new ManualResetEvent(false); + private readonly ManualResetEvent m_shutdownEvent = new(false); private readonly SslProtocols m_sslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13; private TcpListener m_listener; @@ -64,8 +64,7 @@ namespace OSHttpServer /// Factory used to create es. /// Certificate to use /// which HTTPS protocol to use, default is TLS. - protected OSHttpListener(IPAddress address, int port, X509Certificate certificate, - SslProtocols protocols) + protected OSHttpListener(IPAddress address, int port, X509Certificate certificate, SslProtocols protocols) : this(address, port) { m_certificate = certificate; @@ -109,11 +108,10 @@ namespace OSHttpServer set { m_logWriter = value ?? NullLogWriter.Instance; - if (m_certificate != null) - m_logWriter.Write(this, LogPrio.Info, - "HTTPS(" + m_sslProtocols + ") listening on " + m_address + ":" + m_port); + if (m_certificate is not null) + m_logWriter.Write(this, LogPrio.Info, $"HTTPS({m_sslProtocols}) listening on {m_address}:{m_port}"); else - m_logWriter.Write(this, LogPrio.Info, "HTTP listening on " + m_address + ":" + m_port); + m_logWriter.Write(this, LogPrio.Info, "$HTTP listening on {m_address}:{m_port}"); } } @@ -157,9 +155,9 @@ namespace OSHttpServer if(socket.Connected) { - m_logWriter.Write(this, LogPrio.Debug, "Accepted connection from: " + socket.RemoteEndPoint); + m_logWriter.Write(this, LogPrio.Debug, $"Accepted connection from: {socket.RemoteEndPoint}"); - if (m_certificate != null) + if (m_certificate is not null) m_contextFactory.CreateSecureContext(socket, m_certificate, m_sslProtocols, m_clientCertValCallback); else m_contextFactory.CreateContext(socket); @@ -204,7 +202,7 @@ namespace OSHttpServer { if(Accepted!=null) { - ClientAcceptedEventArgs args = new ClientAcceptedEventArgs(socket); + ClientAcceptedEventArgs args = new(socket); Accepted?.Invoke(this, args); return !args.Revoked; } diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequest.cs index a0bdaeceec..5b69562b03 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequest.cs @@ -4,6 +4,7 @@ using System.IO; using System.Net; using System.Text; using System.Web; +using OpenSim.Framework; using OSHttpServer.Exceptions; @@ -362,7 +363,7 @@ namespace OSHttpServer break; case "forwarded": - string[] parts = value.Split(new char[]{';'}); + string[] parts = value.Split(Util.SplitSemicolonArray); string addr = string.Empty; for(int i = 0; i < parts.Length; ++i) { @@ -386,7 +387,7 @@ namespace OSHttpServer case "x-forwarded-for": if (value.Length > 7) { - string[] xparts = value.Split(new char[]{','}); + string[] xparts = value.Split(Util.SplitCommaArray); if(xparts.Length > 0) { string xs = xparts[0].Trim(); diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequestParser.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequestParser.cs index f63a30fb34..4cd8ab7328 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequestParser.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/HttpRequestParser.cs @@ -11,11 +11,11 @@ namespace OSHttpServer.Parser public class HttpRequestParser : IHttpRequestParser { private ILogWriter m_log; - private readonly HeaderEventArgs m_headerArgs = new HeaderEventArgs(); - private readonly BodyEventArgs m_bodyEventArgs = new BodyEventArgs(); - private readonly RequestLineEventArgs m_requestLineArgs = new RequestLineEventArgs(); - private osUTF8Slice m_curHeaderName = new osUTF8Slice(); - private osUTF8Slice m_curHeaderValue = new osUTF8Slice(); + private readonly HeaderEventArgs m_headerArgs = new(); + private readonly BodyEventArgs m_bodyEventArgs = new(); + private readonly RequestLineEventArgs m_requestLineArgs = new(); + private osUTF8Slice m_curHeaderName = new(); + private osUTF8Slice m_curHeaderValue = new(); private int m_bodyBytesLeft; /// @@ -68,7 +68,7 @@ namespace OSHttpServer.Parser if (m_bodyBytesLeft == 0) { // got a complete request. - m_log.Write(this, LogPrio.Trace, "Request parsed successfully."); + m_log.Write(this, LogPrio.Trace, "Request parsed successfully"); OnRequestCompleted(); Clear(); } @@ -108,41 +108,42 @@ namespace OSHttpServer.Parser //todo: In the interest of robustness, servers SHOULD ignore any empty line(s) received where a Request-Line is expected. // In other words, if the server is reading the protocol stream at the beginning of a message and receives a CRLF first, it should ignore the CRLF. // - m_log.Write(this, LogPrio.Debug, "Got request: " + value); + m_log.Write(this, LogPrio.Debug, $"Got request: {value}"); //Request-Line = Method SP Request-URI SP HTTP-Version CRLF int pos = value.IndexOf(' '); - if (pos == -1 || pos + 1 >= value.Length) + int oldPos = pos + 1; + if (pos == -1 || oldPos >= value.Length) { - m_log.Write(this, LogPrio.Warning, "Invalid request line, missing Method. Line: " + value); - throw new BadRequestException("Invalid request line, missing Method. Line: " + value); + m_log.Write(this, LogPrio.Warning, $"Invalid request line, missing Method. Line: {value}"); + throw new BadRequestException($"Invalid request line, missing Method. Line: {value}"); } - string method = value.Substring(0, pos).ToUpper(); - int oldPos = pos + 1; + string method = value[..pos].ToUpper(); pos = value.IndexOf(' ', oldPos); if (pos == -1) { m_log.Write(this, LogPrio.Warning, "Invalid request line, missing URI. Line: " + value); throw new BadRequestException("Invalid request line, missing URI. Line: " + value); } - string path = value.Substring(oldPos, pos - oldPos); + string path = value[oldPos..pos]; if (path.Length > 4196) throw new BadRequestException("Too long URI."); if (path == "*") throw new BadRequestException("Not supported URI."); - if (pos + 1 >= value.Length) + oldPos = pos + 1; + if (oldPos >= value.Length) { - m_log.Write(this, LogPrio.Warning, "Invalid request line, missing HTTP-Version. Line: " + value); - throw new BadRequestException("Invalid request line, missing HTTP-Version. Line: " + value); + m_log.Write(this, LogPrio.Warning, $"Invalid request line, missing HTTP-Version. Line: {value}"); + throw new BadRequestException($"Invalid request line, missing HTTP-Version. Line: {value}"); } - string version = value.Substring(pos + 1); - if (version.Length < 4 || string.Compare(version.Substring(0, 4), "HTTP", true) != 0) + string version = value[oldPos..]; + if (version.Length < 4 || string.Compare(version[..4], "HTTP", true) != 0) { - m_log.Write(this, LogPrio.Warning, "Invalid HTTP version in request line. Line: " + value); - throw new BadRequestException("Invalid HTTP version in Request line. Line: " + value); + m_log.Write(this, LogPrio.Warning, $"Invalid HTTP version in request line. Line: {value}"); + throw new BadRequestException($"Invalid HTTP version in Request line. Line: {value}"); } if(RequestLineReceived != null) @@ -269,7 +270,7 @@ namespace OSHttpServer.Parser if (m_bodyBytesLeft == 0) { CurrentState = RequestParserState.FirstLine; - m_log.Write(this, LogPrio.Trace, "Request parsed successfully (no content)."); + m_log.Write(this, LogPrio.Trace, "Request parsed successfully (no content)"); OnRequestCompleted(); Clear(); return currentPos; @@ -288,9 +289,8 @@ namespace OSHttpServer.Parser { if (startPos == -1) { - m_log.Write(this, LogPrio.Warning, - "Expected header name, got colon on line " + currentLine); - throw new BadRequestException("Expected header name, got colon on line " + currentLine); + m_log.Write(this, LogPrio.Warning, $"Expected header name, got colon on line {currentLine}"); + throw new BadRequestException($"Expected header name, got colon on line {currentLine}"); } m_curHeaderName = new osUTF8Slice(buffer, startPos, currentPos - startPos); handledBytes = currentPos + 1; @@ -302,15 +302,15 @@ namespace OSHttpServer.Parser } else if (!char.IsLetterOrDigit(ch) && ch != '-') { - m_log.Write(this, LogPrio.Warning, "Invalid character in header name on line " + currentLine); - throw new BadRequestException("Invalid character in header name on line " + currentLine); + m_log.Write(this, LogPrio.Warning, $"Invalid character in header name on line {currentLine}"); + throw new BadRequestException($"Invalid character in header name on line {currentLine}"); } if (startPos == -1) startPos = currentPos; else if (currentPos - startPos > 200) { - m_log.Write(this, LogPrio.Warning, "Invalid header name on line " + currentLine); - throw new BadRequestException("Invalid header name on line " + currentLine); + m_log.Write(this, LogPrio.Warning, $"Invalid header name on line {currentLine}"); + throw new BadRequestException($"Invalid header name on line {currentLine}"); } break; case RequestParserState.AfterName: @@ -332,21 +332,22 @@ namespace OSHttpServer.Parser { if (currentPos - startPos > 256) { - m_log.Write(this, LogPrio.Warning, "header value too far" + currentLine); - throw new BadRequestException("header value too far" + currentLine); + m_log.Write(this, LogPrio.Warning, $"header value too far {currentLine}"); + throw new BadRequestException($"header value too far {currentLine}"); } } else { int newLineSize = GetLineBreakSize(buffer, currentPos); - if (newLineSize > 0 && currentPos + newLineSize < endOfBufferPos && - char.IsWhiteSpace((char)buffer[currentPos + newLineSize])) + int tsize = currentPos + newLineSize; + if (newLineSize > 0 && tsize < endOfBufferPos && + char.IsWhiteSpace((char)buffer[tsize])) { if (currentPos - startPos > 256) { - m_log.Write(this, LogPrio.Warning, "header value too" + currentLine); - throw new BadRequestException("header value too far" + currentLine); - } + m_log.Write(this, LogPrio.Warning, $"header value too far {currentLine}"); + throw new BadRequestException($"header value too far {currentLine}"); + } ++currentPos; } else @@ -363,23 +364,23 @@ namespace OSHttpServer.Parser if (ch == '\r' || ch == '\n') { if (m_curHeaderName.Length == 0) - throw new BadRequestException("Missing header on line " + currentLine); - + throw new BadRequestException($"Missing header on line {currentLine}"); + if (currentPos - startPos > 8190) { - m_log.Write(this, LogPrio.Warning, "Too large header value on line " + currentLine); - throw new BadRequestException("Too large header value on line " + currentLine); + m_log.Write(this, LogPrio.Warning, $"Too large header value on line {currentLine}"); + throw new BadRequestException($"Too large header value on line {currentLine}"); } // Header fields can be extended over multiple lines by preceding each extra line with at // least one SP or HT. int newLineSize = GetLineBreakSize(buffer, currentPos); - if (endOfBufferPos > currentPos + newLineSize - && (buffer[currentPos + newLineSize] == ' ' || buffer[currentPos + newLineSize] == '\t')) + int tnext = currentPos + newLineSize; + if (endOfBufferPos > tnext && (buffer[tnext] == ' ' || buffer[tnext] == '\t')) { if (startPos != -1) { - osUTF8Slice osUTF8SliceTmp = new osUTF8Slice(buffer, startPos, currentPos - startPos); + osUTF8Slice osUTF8SliceTmp = new(buffer, startPos, currentPos - startPos); if (m_curHeaderValue.Length == 0) m_curHeaderValue = osUTF8SliceTmp.Clone(); else @@ -393,13 +394,13 @@ namespace OSHttpServer.Parser } else { - osUTF8Slice osUTF8SliceTmp = new osUTF8Slice(buffer, startPos, currentPos - startPos); + osUTF8Slice osUTF8SliceTmp = new(buffer, startPos, currentPos - startPos); if (m_curHeaderValue.Length == 0) m_curHeaderValue = osUTF8SliceTmp.Clone(); else m_curHeaderValue.Append(osUTF8SliceTmp); - m_log.Write(this, LogPrio.Trace, "Header [" + m_curHeaderName + ": " + m_curHeaderValue + "]"); + m_log.Write(this, LogPrio.Trace, $"Header [{m_curHeaderName}:{m_curHeaderValue}]"); OnHeader(); @@ -432,23 +433,23 @@ namespace OSHttpServer.Parser return handledBytes; } - int GetLineBreakSize(byte[] buffer, int offset) + static int GetLineBreakSize(in byte[] buffer, int offset) { - if (buffer[offset] == '\r') + byte c = buffer[offset]; + if (c == '\r') { - if (buffer.Length > offset + 1 && buffer[offset + 1] == '\n') + ++offset; + if (buffer.Length > offset && buffer[offset] == '\n') return 2; else throw new BadRequestException("Got invalid linefeed."); } - else if (buffer[offset] == '\n') + else if (c == '\n') { - if (buffer.Length == offset + 1) + ++offset; + if (buffer.Length == offset) return 1; // linux line feed - if (buffer[offset + 1] != '\r') - return 1; // linux line feed - else - return 2; // win line feed + return buffer[offset] == '\r' ? 2 : 1; } else return 0; diff --git a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/ILogWriter.cs b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/ILogWriter.cs index 790c9a500d..03093d0afd 100644 --- a/OpenSim/Framework/Servers/HttpServer/OSHttpServer/ILogWriter.cs +++ b/OpenSim/Framework/Servers/HttpServer/OSHttpServer/ILogWriter.cs @@ -1,6 +1,4 @@ -using System; -using System.Diagnostics; -using System.Text; +using System.Runtime.CompilerServices; namespace OSHttpServer { @@ -68,7 +66,7 @@ namespace OSHttpServer /// /// The logging instance. /// - public static readonly NullLogWriter Instance = new NullLogWriter(); + public static readonly NullLogWriter Instance = new(); /// /// Writes everything to null @@ -76,6 +74,7 @@ namespace OSHttpServer /// object that wrote the log entry. /// Importance of the log message /// The message. + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Write(object source, LogPrio prio, string message) {} } } diff --git a/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs b/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs index 9126cfb5f4..4f16a4644b 100644 --- a/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs +++ b/OpenSim/Framework/ServiceAuth/BasicHttpAuthentication.cs @@ -75,7 +75,7 @@ namespace OpenSim.Framework.ServiceAuth string recovered = Util.Base64ToString(data); if (!String.IsNullOrEmpty(recovered)) { - string[] parts = recovered.Split(new char[] { ':' }); + string[] parts = recovered.Split(Util.SplitColonArray); if (parts.Length >= 2) { return m_Username.Equals(parts[0]) && m_Password.Equals(parts[1]); diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 34b7ebda54..050f826c99 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -172,6 +172,12 @@ namespace OpenSim.Framework private static readonly string regexInvalidPathChars = $"[{new String(Path.GetInvalidPathChars())}]"; private static readonly object XferLock = new(); + public static readonly char[] SplitCommaArray = new char[] { ',' }; + public static readonly char[] SplitDotArray = new char[] { '.' }; + public static readonly char[] SplitColonArray = new char[] { ':' }; + public static readonly char[] SplitSemicolonArray = new char[] { ';' }; + public static readonly char[] SplitSlashArray = new char[] { '/' }; + /// /// Thread pool used for Util.FireAndForget if FireAndForgetMethod.SmartThreadPool is used /// @@ -565,7 +571,7 @@ namespace OpenSim.Framework string host; int port = 80; - string[] parts = inputName.Split(new char[] { ':' }); + string[] parts = inputName.Split(Util.SplitColonArray); int indx; if (parts.Length == 0) return false; @@ -621,7 +627,7 @@ namespace OpenSim.Framework // http://grid.example.com "region name" // http://grid.example.com - string[] parts = inputName.Split(new char[] { ' ' }); + string[] parts = inputName.Split(); if (parts.Length == 0) return false; @@ -1849,7 +1855,7 @@ namespace OpenSim.Framework /// public static T GetConfigVarFromSections(IConfigSource config, string varname, string[] sections, object val) { - foreach (string section in sections) + foreach (string section in sections.AsSpan()) { IConfig cnf = config.Configs[section]; if (cnf == null) @@ -1864,9 +1870,8 @@ namespace OpenSim.Framework else if (typeof(T) == typeof(float)) val = cnf.GetFloat(varname, (float)val); else - m_log.Error($"[UTIL]: Unhandled type {typeof(T)}"); + m_log.ErrorFormat("[UTIL]: Unhandled type {0}", typeof(T)); } - return (T)val; } @@ -2440,7 +2445,7 @@ namespace OpenSim.Framework else { // uh? - m_log.Debug($"[UTILS]: Got OSD of unexpected type {buffer.Type.ToString()}"); + m_log.Debug($"[UTILS]: Got OSD of unexpected type {buffer.Type}"); return null; } } @@ -2548,7 +2553,7 @@ namespace OpenSim.Framework try { - port1 = uri.Split(new char[] { ':' })[2]; + port1 = uri.Split(Util.SplitColonArray)[2]; } catch { } @@ -3494,7 +3499,7 @@ namespace OpenSim.Framework if (xff.Length == 0) return null; - string[] parts = xff.Split(new char[] { ',' }); + string[] parts = xff.Split(Util.SplitCommaArray); if (parts.Length > 0) { try @@ -4186,7 +4191,7 @@ namespace OpenSim.Framework // in the agent circuit data for foreigners if (lastName.Contains('@')) { - string[] parts = firstName.Split(new char[] { '.' }); + string[] parts = firstName.Split(Util.SplitDotArray); if (parts.Length == 2) return CalcUniversalIdentifier(id, agentsURI, parts[0].Trim() + " " + parts[1].Trim()); } diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs index baa82760d9..87d2f44f37 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetXferUploader.cs @@ -556,7 +556,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction else if (textures > 0) { - string[] parts = line.Split(new char[] {' '}); + string[] parts = line.Split(); UUID tx = new UUID(parts[1]); int id = Convert.ToInt32(parts[0]); @@ -634,7 +634,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } else if (textures > 0) { - string[] parts = line.Split(new char[] {' '}); + string[] parts = line.Split(); UUID tx = new UUID(parts[1]); int id = Convert.ToInt32(parts[0]); diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index 10f2b69bdf..202ff7a702 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs @@ -306,7 +306,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends m_uMan.AddUser(agentID, f, l, url); string name = m_uMan.GetUserName(agentID); - string[] parts = name.Trim().Split(new char[] { ' ' }); + string[] parts = name.Trim().Split(); if (parts.Length == 2) { first = parts[0]; diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index 5d77201320..3789983e48 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs @@ -247,7 +247,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library private string GetInventoryPathFromName(string name) { - string[] parts = name.Split(new char[] { ' ' }); + string[] parts = name.Split(); if (parts.Length == 3) { name = string.Empty; diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs index cd89d8646e..e5649f1cb6 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs @@ -117,7 +117,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement // This is it! Let's ask the other world if (words[0].Contains(".")) { - string[] names = words[0].Split(new char[] { '.' }); + string[] names = words[0].Split(Util.SplitDotArray); if (names.Length >= 2) { string uriStr = "http://" + words[1]; diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModifier.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModifier.cs index 1bc9422972..6d9e448425 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModifier.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModifier.cs @@ -27,7 +27,7 @@ using System; using System.Reflection; using log4net; - +using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; namespace OpenSim.Region.CoreModules.World.Terrain @@ -83,7 +83,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain { data.shape = arg.StartsWith("-ell=") ? "ellipse" : "rectangle"; val = arg.Substring(arg.IndexOf("=") + 1); - string[] coords = val.Split(new char[] {','}); + string[] coords = val.Split(Util.SplitCommaArray); if ((coords.Length < 3) || (coords.Length > 4)) { result = String.Format("Bad format for shape parameter {0}", arg); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6e962c5856..1fe798d809 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -15260,7 +15260,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private string Name2Username(string name) { - string[] parts = name.Split(new char[] {' '}); + string[] parts = name.Split(); if (parts.Length < 2) return name.ToLower(); if (parts[1].Equals("Resident")) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index cdbcc28aa7..8213f5f9dc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -359,7 +359,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api bool error = false; if (!string.IsNullOrWhiteSpace(ownerPerm)) { - ids = ownerPerm.Split(new char[] {','}); + ids = ownerPerm.Split(Util.SplitCommaArray); foreach (string id in ids) { string current = id.Trim(); @@ -415,7 +415,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api error = false; if (!string.IsNullOrWhiteSpace(creatorPerm)) { - ids = creatorPerm.Split(new char[] {','}); + ids = creatorPerm.Split(Util.SplitCommaArray); foreach (string id in ids) { string current = id.Trim(); diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index d70f46342e..2b9566867f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -89,7 +89,7 @@ namespace OpenSim.Region.ScriptEngine.Shared { str = str.Replace('<', ' '); str = str.Replace('>', ' '); - string[] tmps = str.Split(new Char[] {','}); + string[] tmps = str.Split(Util.SplitCommaArray); if (tmps.Length < 3) { z = y = x = 0; @@ -427,7 +427,7 @@ namespace OpenSim.Region.ScriptEngine.Shared { str = str.Replace('<', ' '); str = str.Replace('>', ' '); - string[] tmps = str.Split(new Char[] {','}); + string[] tmps = str.Split(Util.SplitCommaArray); if (tmps.Length < 4 || !Double.TryParse(tmps[3], NumberStyles.Float, Culture.NumberFormatInfo, out s)) {