- Add Util.isUUID
- Add tests for Util.isUUID - First part of the fix for protocol interoperability between viewer 1.20 and 1.21 for friend offers.0.6.0-stable
parent
6d4f8b38aa
commit
499f1428f7
|
@ -137,5 +137,20 @@ namespace OpenSim.Framework.Tests
|
||||||
"Normalized vector generated from vector does not have magnitude of 1.");
|
"Normalized vector generated from vector does not have magnitude of 1.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void UUIDTests()
|
||||||
|
{
|
||||||
|
Assert.IsTrue(Util.isUUID("01234567-89ab-Cdef-0123-456789AbCdEf"),
|
||||||
|
"A correct UUID wasn't recognized.");
|
||||||
|
Assert.IsFalse(Util.isUUID("FOOBAR67-89ab-Cdef-0123-456789AbCdEf"),
|
||||||
|
"UUIDs with non-hex characters are recognized as correct UUIDs.");
|
||||||
|
Assert.IsFalse(Util.isUUID("01234567"),
|
||||||
|
"Too short UUIDs are regognized as correct UUIDs.");
|
||||||
|
Assert.IsFalse(Util.isUUID("01234567-89ab-Cdef-0123-456789AbCdEf0"),
|
||||||
|
"Too long UUIDs are regognized as correct UUIDs.");
|
||||||
|
Assert.IsFalse(Util.isUUID("01234567-89ab-Cdef-0123+456789AbCdEf"),
|
||||||
|
"UUIDs with wrong format are recognized as correct UUIDs.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,8 @@ namespace OpenSim.Framework
|
||||||
private static readonly DateTime unixEpoch =
|
private static readonly DateTime unixEpoch =
|
||||||
DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", DateTimeFormatInfo.InvariantInfo).ToUniversalTime();
|
DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", DateTimeFormatInfo.InvariantInfo).ToUniversalTime();
|
||||||
|
|
||||||
|
private static readonly Regex UUIDPattern = new Regex("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$");
|
||||||
|
|
||||||
#region Vector Equations
|
#region Vector Equations
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -796,5 +798,10 @@ namespace OpenSim.Framework
|
||||||
x += rx;
|
x += rx;
|
||||||
y += ry;
|
y += ry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool isUUID(string s)
|
||||||
|
{
|
||||||
|
return UUIDPattern.IsMatch(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -396,6 +396,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
|
||||||
|
|
||||||
UUID transactionID = UUID.Random();
|
UUID transactionID = UUID.Random();
|
||||||
|
|
||||||
|
// 1.20 protocol sends an UUID in the message field, instead of the friendship offer text.
|
||||||
|
// For interoperability, we have to clear that
|
||||||
|
if (Util.isUUID(message)) message = "";
|
||||||
|
|
||||||
GridInstantMessage msg = new GridInstantMessage();
|
GridInstantMessage msg = new GridInstantMessage();
|
||||||
msg.fromAgentID = fromAgentID.Guid;
|
msg.fromAgentID = fromAgentID.Guid;
|
||||||
msg.fromAgentSession = UUID.Zero.Guid; // server IMs don't have a session
|
msg.fromAgentSession = UUID.Zero.Guid; // server IMs don't have a session
|
||||||
|
|
Loading…
Reference in New Issue