From 0505fd54e4fb260d5ecfe7f4a019cfea40ccac78 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 14 Sep 2022 18:41:13 +0100 Subject: [PATCH] simplify CleanString a bit more --- OpenSim/Framework/Util.cs | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 48c0b6397a..69a66e205a 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -2052,28 +2052,15 @@ namespace OpenSim.Framework public static string CleanString(string input) { - if (input.Length == 0) - return input; - - int clip = input.Length; - - // Test for ++ string terminator - int pos = input.IndexOf('\0'); - if (pos != -1 && pos < clip) - clip = pos; - - // Test for CR - pos = input.IndexOf('\r'); - if (pos != -1 && pos < clip) - clip = pos; - - // Test for LF - pos = input.IndexOf('\n'); - if (pos != -1 && pos < clip) - clip = pos; - - // Truncate string before first end-of-line character found - return input.Substring(0, clip); + if (input.Length > 0) + { + for (int i = 0; i < input.Length; i++) + { + if (input[i] == '\0' || input[i] == '\r' || input[i] == '\n') + return input.Substring(0, i); + } + } + return input; } ///