diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs index a973ed2981..0224356fe4 100644 --- a/OpenSim/Framework/Tests/UtilTest.cs +++ b/OpenSim/Framework/Tests/UtilTest.cs @@ -137,5 +137,20 @@ namespace OpenSim.Framework.Tests "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."); + } } } diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index c5334a88a4..b8080ec573 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -64,6 +64,8 @@ namespace OpenSim.Framework private static readonly DateTime unixEpoch = 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 /// @@ -796,5 +798,10 @@ namespace OpenSim.Framework x += rx; y += ry; } + + public static bool isUUID(string s) + { + return UUIDPattern.IsMatch(s); + } } } diff --git a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs index 605b6a226a..33ca632a7c 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs @@ -396,6 +396,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends 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(); msg.fromAgentID = fromAgentID.Guid; msg.fromAgentSession = UUID.Zero.Guid; // server IMs don't have a session