diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Util.cs | 11 | ||||
-rw-r--r-- | OpenSim/Services/GridService/GridService.cs | 14 | ||||
-rw-r--r-- | OpenSim/Services/GridService/HypergridLinker.cs | 2 |
3 files changed, 19 insertions, 8 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 4fd8a2d..f511494 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -2102,5 +2102,16 @@ namespace OpenSim.Framework | |||
2102 | return firstName + "." + lastName + " " + "@" + uri.Authority; | 2102 | return firstName + "." + lastName + " " + "@" + uri.Authority; |
2103 | } | 2103 | } |
2104 | #endregion | 2104 | #endregion |
2105 | |||
2106 | /// <summary> | ||
2107 | /// Escapes the special characters used in "LIKE". | ||
2108 | /// </summary> | ||
2109 | /// <remarks> | ||
2110 | /// For example: EscapeForLike("foo_bar%baz") = "foo\_bar\%baz" | ||
2111 | /// </remarks> | ||
2112 | public static string EscapeForLike(string str) | ||
2113 | { | ||
2114 | return str.Replace("_", "\\_").Replace("%", "\\%"); | ||
2115 | } | ||
2105 | } | 2116 | } |
2106 | } | 2117 | } |
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index ee3b858..daebf8b 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -185,15 +185,15 @@ namespace OpenSim.Services.GridService | |||
185 | 185 | ||
186 | if (!m_AllowDuplicateNames) | 186 | if (!m_AllowDuplicateNames) |
187 | { | 187 | { |
188 | List<RegionData> dupe = m_Database.Get(regionInfos.RegionName, scopeID); | 188 | List<RegionData> dupe = m_Database.Get(Util.EscapeForLike(regionInfos.RegionName), scopeID); |
189 | if (dupe != null && dupe.Count > 0) | 189 | if (dupe != null && dupe.Count > 0) |
190 | { | 190 | { |
191 | foreach (RegionData d in dupe) | 191 | foreach (RegionData d in dupe) |
192 | { | 192 | { |
193 | if (d.RegionID != regionInfos.RegionID) | 193 | if (d.RegionID != regionInfos.RegionID) |
194 | { | 194 | { |
195 | m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.", | 195 | m_log.WarnFormat("[GRID SERVICE]: Region tried to register using a duplicate name. New region: {0} ({1}), existing region: {2} ({3}).", |
196 | regionInfos.RegionName, regionInfos.RegionID); | 196 | regionInfos.RegionName, regionInfos.RegionID, d.RegionName, d.RegionID); |
197 | return "Duplicate region name"; | 197 | return "Duplicate region name"; |
198 | } | 198 | } |
199 | } | 199 | } |
@@ -359,7 +359,7 @@ namespace OpenSim.Services.GridService | |||
359 | 359 | ||
360 | public GridRegion GetRegionByName(UUID scopeID, string name) | 360 | public GridRegion GetRegionByName(UUID scopeID, string name) |
361 | { | 361 | { |
362 | List<RegionData> rdatas = m_Database.Get(name, scopeID); | 362 | List<RegionData> rdatas = m_Database.Get(Util.EscapeForLike(name), scopeID); |
363 | if ((rdatas != null) && (rdatas.Count > 0)) | 363 | if ((rdatas != null) && (rdatas.Count > 0)) |
364 | return RegionData2RegionInfo(rdatas[0]); // get the first | 364 | return RegionData2RegionInfo(rdatas[0]); // get the first |
365 | 365 | ||
@@ -377,7 +377,7 @@ namespace OpenSim.Services.GridService | |||
377 | { | 377 | { |
378 | // m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name); | 378 | // m_log.DebugFormat("[GRID SERVICE]: GetRegionsByName {0}", name); |
379 | 379 | ||
380 | List<RegionData> rdatas = m_Database.Get(name + "%", scopeID); | 380 | List<RegionData> rdatas = m_Database.Get(Util.EscapeForLike(name) + "%", scopeID); |
381 | 381 | ||
382 | int count = 0; | 382 | int count = 0; |
383 | List<GridRegion> rinfos = new List<GridRegion>(); | 383 | List<GridRegion> rinfos = new List<GridRegion>(); |
@@ -586,7 +586,7 @@ namespace OpenSim.Services.GridService | |||
586 | 586 | ||
587 | string regionName = cmd[3]; | 587 | string regionName = cmd[3]; |
588 | 588 | ||
589 | List<RegionData> regions = m_Database.Get(regionName, UUID.Zero); | 589 | List<RegionData> regions = m_Database.Get(Util.EscapeForLike(regionName), UUID.Zero); |
590 | if (regions == null || regions.Count < 1) | 590 | if (regions == null || regions.Count < 1) |
591 | { | 591 | { |
592 | MainConsole.Instance.Output("No region with name {0} found", regionName); | 592 | MainConsole.Instance.Output("No region with name {0} found", regionName); |
@@ -716,7 +716,7 @@ namespace OpenSim.Services.GridService | |||
716 | return; | 716 | return; |
717 | } | 717 | } |
718 | 718 | ||
719 | List<RegionData> regions = m_Database.Get(cmd[3], UUID.Zero); | 719 | List<RegionData> regions = m_Database.Get(Util.EscapeForLike(cmd[3]), UUID.Zero); |
720 | if (regions == null || regions.Count < 1) | 720 | if (regions == null || regions.Count < 1) |
721 | { | 721 | { |
722 | MainConsole.Instance.Output("Region not found"); | 722 | MainConsole.Instance.Output("Region not found"); |
diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index 743d089..073197f 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs | |||
@@ -387,7 +387,7 @@ namespace OpenSim.Services.GridService | |||
387 | m_log.DebugFormat("[HYPERGRID LINKER]: Request to unlink {0}", mapName); | 387 | m_log.DebugFormat("[HYPERGRID LINKER]: Request to unlink {0}", mapName); |
388 | GridRegion regInfo = null; | 388 | GridRegion regInfo = null; |
389 | 389 | ||
390 | List<RegionData> regions = m_Database.Get(mapName, m_ScopeID); | 390 | List<RegionData> regions = m_Database.Get(Util.EscapeForLike(mapName), m_ScopeID); |
391 | if (regions != null && regions.Count > 0) | 391 | if (regions != null && regions.Count > 0) |
392 | { | 392 | { |
393 | OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]); | 393 | OpenSim.Framework.RegionFlags rflags = (OpenSim.Framework.RegionFlags)Convert.ToInt32(regions[0].Data["flags"]); |