diff options
author | Justin Clark-Casey (justincc) | 2013-12-14 02:33:08 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-12-14 02:33:08 +0000 |
commit | 38d7d46c171eaf16e09b5c6c34fba8dd7cb9e2b8 (patch) | |
tree | 41e5078aba494d7102a91f320639e83de1d30e81 /OpenSim/Framework | |
parent | Merge branch 'justincc-master' (diff) | |
parent | ParseNotecardToList() returned data past end of notecard text (mantis #6881). (diff) | |
download | opensim-SC_OLD-38d7d46c171eaf16e09b5c6c34fba8dd7cb9e2b8.zip opensim-SC_OLD-38d7d46c171eaf16e09b5c6c34fba8dd7cb9e2b8.tar.gz opensim-SC_OLD-38d7d46c171eaf16e09b5c6c34fba8dd7cb9e2b8.tar.bz2 opensim-SC_OLD-38d7d46c171eaf16e09b5c6c34fba8dd7cb9e2b8.tar.xz |
Merge branch 'justincc-master'
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/SLUtil.cs | 30 |
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; |