aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKevin Cozens2013-12-09 03:15:40 -0500
committerJustin Clark-Casey (justincc)2013-12-14 02:25:28 +0000
commit957449e62cda67a641162043e21cd102f6f99080 (patch)
tree2c4e36746b067725b78f52009ec842fa816d95c0
parentWrap analysis of the particle system in the UUID Gatherer in a separate try/c... (diff)
downloadopensim-SC_OLD-957449e62cda67a641162043e21cd102f6f99080.zip
opensim-SC_OLD-957449e62cda67a641162043e21cd102f6f99080.tar.gz
opensim-SC_OLD-957449e62cda67a641162043e21cd102f6f99080.tar.bz2
opensim-SC_OLD-957449e62cda67a641162043e21cd102f6f99080.tar.xz
ParseNotecardToList() returned data past end of notecard text (mantis #6881).
-rw-r--r--OpenSim/Framework/SLUtil.cs30
1 files changed, 15 insertions, 15 deletions
diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs
index 537de7a..cb73e8f 100644
--- a/OpenSim/Framework/SLUtil.cs
+++ b/OpenSim/Framework/SLUtil.cs
@@ -247,12 +247,18 @@ namespace OpenSim.Framework
247 /// <returns></returns> 247 /// <returns></returns>
248 public static List<string> ParseNotecardToList(string rawInput) 248 public static List<string> ParseNotecardToList(string rawInput)
249 { 249 {
250 string[] input = rawInput.Replace("\r", "").Split('\n'); 250 string[] input;
251 int idx = 0; 251 int idx = 0;
252 int level = 0; 252 int level = 0;
253 List<string> output = new List<string>(); 253 List<string> output = new List<string>();
254 string[] words; 254 string[] words;
255 255
256 //The Linden format always ends with a } after the input data.
257 //Strip off trailing } so there is nothing after the input data.
258 int i = rawInput.LastIndexOf("}");
259 rawInput = rawInput.Remove(i, rawInput.Length-i);
260 input = rawInput.Replace("\r", "").Split('\n');
261
256 while (idx < input.Length) 262 while (idx < input.Length)
257 { 263 {
258 if (input[idx] == "{") 264 if (input[idx] == "{")
@@ -287,24 +293,18 @@ namespace OpenSim.Framework
287 break; 293 break;
288 if (words[0] == "Text") 294 if (words[0] == "Text")
289 { 295 {
290 int len = int.Parse(words[2]); 296 idx++; //Now points to first line of notecard text
291 idx++;
292 297
293 int count = -1; 298 //Number of lines in notecard.
299 int lines = input.Length - idx;
300 int line = 0;
294 301
295 while (count < len && idx < input.Length) 302 while (line < lines)
296 { 303 {
297 // int l = input[idx].Length; 304// m_log.DebugFormat("[PARSE NOTECARD]: Adding line {0}", input[idx]);
298 string ln = input[idx]; 305 output.Add(input[idx]);
299
300 int need = len-count-1;
301 if (ln.Length > need)
302 ln = ln.Substring(0, need);
303
304// m_log.DebugFormat("[PARSE NOTECARD]: Adding line {0}", ln);
305 output.Add(ln);
306 count += ln.Length + 1;
307 idx++; 306 idx++;
307 line++;
308 } 308 }
309 309
310 return output; 310 return output;