* Patch from Melanie provides Util.CleanString and uses it on the prim name and description. Thanks Melanie.

afrisby
Teravus Ovares 2007-12-28 23:19:03 +00:00
parent 04f284e175
commit 0631151e08
3 changed files with 30 additions and 8 deletions

View File

@ -222,10 +222,7 @@ namespace OpenSim.Framework
output.Append(": "); output.Append(": ");
} }
if (bytes[bytes.Length - 1] == 0x00) output.Append(CleanString(UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1)));
output.Append(UTF8Encoding.UTF8.GetString(bytes, 0, bytes.Length - 1));
else
output.Append(UTF8Encoding.UTF8.GetString(bytes));
} }
else else
{ {
@ -406,5 +403,31 @@ namespace OpenSim.Framework
{ {
return lluuid.UUID.ToString("n"); return lluuid.UUID.ToString("n");
} }
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);
}
} }
} }

View File

@ -749,7 +749,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID)) if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID))
{ {
group.SetPartName(name, primLocalID); group.SetPartName(Util.CleanString(name), primLocalID);
} }
} }
} }
@ -766,7 +766,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID)) if (PermissionsMngr.CanEditObject(remoteClient.AgentId, group.UUID))
{ {
group.SetPartDescription(description.Replace("\0",""), primLocalID); group.SetPartDescription(Util.CleanString(description), primLocalID);
} }
} }
} }

View File

@ -1086,7 +1086,6 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="name"></param> /// <param name="name"></param>
public void SetPartName(string name, uint localID) public void SetPartName(string name, uint localID)
{ {
name = name.Remove(name.Length - 1, 1);
SceneObjectPart part = GetChildPart(localID); SceneObjectPart part = GetChildPart(localID);
if (part != null) if (part != null)
{ {