aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Tests/UtilTest.cs15
-rw-r--r--OpenSim/Framework/Util.cs7
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs4
3 files changed, 26 insertions, 0 deletions
diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs
index a973ed2..0224356 100644
--- a/OpenSim/Framework/Tests/UtilTest.cs
+++ b/OpenSim/Framework/Tests/UtilTest.cs
@@ -137,5 +137,20 @@ namespace OpenSim.Framework.Tests
137 "Normalized vector generated from vector does not have magnitude of 1."); 137 "Normalized vector generated from vector does not have magnitude of 1.");
138 } 138 }
139 } 139 }
140
141 [Test]
142 public void UUIDTests()
143 {
144 Assert.IsTrue(Util.isUUID("01234567-89ab-Cdef-0123-456789AbCdEf"),
145 "A correct UUID wasn't recognized.");
146 Assert.IsFalse(Util.isUUID("FOOBAR67-89ab-Cdef-0123-456789AbCdEf"),
147 "UUIDs with non-hex characters are recognized as correct UUIDs.");
148 Assert.IsFalse(Util.isUUID("01234567"),
149 "Too short UUIDs are regognized as correct UUIDs.");
150 Assert.IsFalse(Util.isUUID("01234567-89ab-Cdef-0123-456789AbCdEf0"),
151 "Too long UUIDs are regognized as correct UUIDs.");
152 Assert.IsFalse(Util.isUUID("01234567-89ab-Cdef-0123+456789AbCdEf"),
153 "UUIDs with wrong format are recognized as correct UUIDs.");
154 }
140 } 155 }
141} 156}
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index c5334a8..b8080ec 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -64,6 +64,8 @@ namespace OpenSim.Framework
64 private static readonly DateTime unixEpoch = 64 private static readonly DateTime unixEpoch =
65 DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", DateTimeFormatInfo.InvariantInfo).ToUniversalTime(); 65 DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", DateTimeFormatInfo.InvariantInfo).ToUniversalTime();
66 66
67 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}$");
68
67 #region Vector Equations 69 #region Vector Equations
68 70
69 /// <summary> 71 /// <summary>
@@ -796,5 +798,10 @@ namespace OpenSim.Framework
796 x += rx; 798 x += rx;
797 y += ry; 799 y += ry;
798 } 800 }
801
802 public static bool isUUID(string s)
803 {
804 return UUIDPattern.IsMatch(s);
805 }
799 } 806 }
800} 807}
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
index 605b6a2..33ca632 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
396 396
397 UUID transactionID = UUID.Random(); 397 UUID transactionID = UUID.Random();
398 398
399 // 1.20 protocol sends an UUID in the message field, instead of the friendship offer text.
400 // For interoperability, we have to clear that
401 if (Util.isUUID(message)) message = "";
402
399 GridInstantMessage msg = new GridInstantMessage(); 403 GridInstantMessage msg = new GridInstantMessage();
400 msg.fromAgentID = fromAgentID.Guid; 404 msg.fromAgentID = fromAgentID.Guid;
401 msg.fromAgentSession = UUID.Zero.Guid; // server IMs don't have a session 405 msg.fromAgentSession = UUID.Zero.Guid; // server IMs don't have a session