From 8cbe74344085f23324d03cbb03bd57d18b0df84b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 8 Feb 2020 16:27:30 +0000 Subject: [PATCH] missing file and remove dead code --- OpenSim/Framework/SLUtil.cs | 257 ------------------ OpenSim/Framework/Util.cs | 13 +- .../JsonStore/JsonStoreScriptModule.cs | 17 +- 3 files changed, 20 insertions(+), 267 deletions(-) diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs index 4b2daa5c18..e626f434b2 100644 --- a/OpenSim/Framework/SLUtil.cs +++ b/OpenSim/Framework/SLUtil.cs @@ -45,7 +45,6 @@ namespace OpenSim.Framework Material = -2 } - #region SL / file extension / content-type conversions /// @@ -334,262 +333,6 @@ namespace OpenSim.Framework #endregion SL / file extension / content-type conversions - private class NotecardReader - { - private string rawInput; - private int lineNumber; - - public int LineNumber - { - get - { - return lineNumber; - } - } - - public NotecardReader(string _rawInput) - { - rawInput = (string)_rawInput.Clone(); - lineNumber = 0; - } - - public string getLine() - { - if(rawInput.Length == 0) - { - throw new NotANotecardFormatException(lineNumber + 1); - } - - int pos = rawInput.IndexOf('\n'); - if(pos < 0) - { - pos = rawInput.Length; - } - - /* cut line from rest */ - ++lineNumber; - string line = rawInput.Substring(0, pos); - if (pos + 1 >= rawInput.Length) - { - rawInput = string.Empty; - } - else - { - rawInput = rawInput.Substring(pos + 1); - } - /* clean up line from double spaces and tabs */ - line = line.Replace("\t", " "); - while(line.IndexOf(" ") >= 0) - { - line = line.Replace(" ", " "); - } - return line.Replace("\r", "").Trim(); - } - - public string getBlock(int length) - { - /* cut line from rest */ - if(length > rawInput.Length) - { - throw new NotANotecardFormatException(lineNumber); - } - string line = rawInput.Substring(0, length); - rawInput = rawInput.Substring(length); - return line; - } - } - - public class NotANotecardFormatException : Exception - { - public int lineNumber; - public NotANotecardFormatException(int _lineNumber) - : base() - { - lineNumber = _lineNumber; - } - } - - private static void skipSection(NotecardReader reader) - { - if (reader.getLine() != "{") - throw new NotANotecardFormatException(reader.LineNumber); - - string line; - while ((line = reader.getLine()) != "}") - { - if(line.IndexOf('{')>=0) - { - throw new NotANotecardFormatException(reader.LineNumber); - } - } - } - - private static void skipInventoryItem(NotecardReader reader) - { - if (reader.getLine() != "{") - throw new NotANotecardFormatException(reader.LineNumber); - - string line; - while((line = reader.getLine()) != "}") - { - string[] data = line.Split(' '); - if(data.Length == 0) - { - continue; - } - if(data[0] == "permissions") - { - skipSection(reader); - } - else if(data[0] == "sale_info") - { - skipSection(reader); - } - else if (line.IndexOf('{') >= 0) - { - throw new NotANotecardFormatException(reader.LineNumber); - } - } - } - - private static void skipInventoryItems(NotecardReader reader) - { - if(reader.getLine() != "{") - { - throw new NotANotecardFormatException(reader.LineNumber); - } - - string line; - while((line = reader.getLine()) != "}") - { - string[] data = line.Split(' '); - if(data.Length == 0) - { - continue; - } - - if(data[0] == "inv_item") - { - skipInventoryItem(reader); - } - else if (line.IndexOf('{') >= 0) - { - throw new NotANotecardFormatException(reader.LineNumber); - } - - } - } - - private static void skipInventory(NotecardReader reader) - { - if (reader.getLine() != "{") - throw new NotANotecardFormatException(reader.LineNumber); - - string line; - while((line = reader.getLine()) != "}") - { - string[] data = line.Split(' '); - if(data[0] == "count") - { - int count = Int32.Parse(data[1]); - for(int i = 0; i < count; ++i) - { - skipInventoryItems(reader); - } - } - else if (line.IndexOf('{') >= 0) - { - throw new NotANotecardFormatException(reader.LineNumber); - } - } - } - - private static string readNotecardText(NotecardReader reader) - { - if (reader.getLine() != "{") - throw new NotANotecardFormatException(reader.LineNumber); - - string notecardString = string.Empty; - string line; - while((line = reader.getLine()) != "}") - { - string[] data = line.Split(' '); - if (data.Length == 0) - { - continue; - } - - if (data[0] == "LLEmbeddedItems") - { - skipInventory(reader); - } - else if(data[0] == "Text" && data.Length == 3) - { - int length = Int32.Parse(data[2]); - notecardString = reader.getBlock(length); - } - else if (line.IndexOf('{') >= 0) - { - throw new NotANotecardFormatException(reader.LineNumber); - } - - } - return notecardString; - } - - private static string readNotecard(byte[] rawInput) - { - string rawIntermedInput = string.Empty; - - /* make up a Raw Encoding here */ - foreach(byte c in rawInput) - { - char d = (char)c; - rawIntermedInput += d; - } - - NotecardReader reader = new NotecardReader(rawIntermedInput); - string line; - try - { - line = reader.getLine(); - } - catch(Exception) - { - return System.Text.Encoding.UTF8.GetString(rawInput); - } - string[] versioninfo = line.Split(' '); - if(versioninfo.Length < 3) - { - return System.Text.Encoding.UTF8.GetString(rawInput); - } - else if(versioninfo[0] != "Linden" || versioninfo[1] != "text") - { - return System.Text.Encoding.UTF8.GetString(rawInput); - } - else - { - /* now we actually decode the Encoding, before we needed it in raw */ - string o = readNotecardText(reader); - byte[] a = new byte[o.Length]; - for(int i = 0; i < o.Length; ++i) - { - a[i] = (byte)o[i]; - } - return System.Text.Encoding.UTF8.GetString(a); - } - } - - /// - /// Parse a notecard in Linden format to a string of ordinary text. - /// - /// - /// - public static string ParseNotecardToString(byte[] rawInput) - { - return readNotecard(rawInput); - } - static char[] seps = new char[] { '\t', '\n' }; static char[] stringseps = new char[] { '|', '\n' }; diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index f57e37f885..cc5a16b384 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -732,14 +732,19 @@ namespace OpenSim.Framework return false; } - public static List GetUUIDsOnString(ref string s, int indx) + public static List GetUUIDsOnString(ref string s, int indx, int len) { var ids = new List(); - if (s.Length < 36) + + int endA = indx + len; + if(endA > s.Length) + endA = s.Length; + if (endA - indx < 36) return ids; - int endA = s.Length - 35; - int endB = s.Length - 26; + int endB = endA - 26; + endA -= 35; + int idbase; int next; int retry; diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index fe8d9621e1..4c5dd02ed3 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs @@ -595,15 +595,20 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore try { - string jsondata = SLUtil.ParseNotecardToString(a.Data); - int result = m_store.SetValue(storeID, path, jsondata,true) ? 1 : 0; + int result; + string[] data = SLUtil.ParseNotecardToArray(a.Data); + if(data.Length == 0) + result = m_store.SetValue(storeID, path, string.Empty, true) ? 1 : 0; + else + { + StringBuilder sb = new StringBuilder(256); + for(int i = 0; i < data.Length; ++i) + sb.AppendLine(data[i]); + result = m_store.SetValue(storeID, path, sb.ToString(),true) ? 1 : 0; + } m_comms.DispatchReply(scriptID, result, "", reqID.ToString()); return; } - catch(SLUtil.NotANotecardFormatException e) - { - m_log.WarnFormat("[JsonStoreScripts]: Notecard parsing failed; assetId {0} at line number {1}", assetID.ToString(), e.lineNumber); - } catch (Exception e) { m_log.WarnFormat("[JsonStoreScripts]: Json parsing failed; {0}", e.Message);