diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index 77ae12ff626..4df9a030549 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs @@ -192,7 +192,7 @@ public List Get(int startX, int startY, int endX, int endY, UUID sco foreach (RegionData r in m_regionData.Values) { if (r.posX + r.sizeX > startX && r.posX <= endX - && r.posY + r.sizeX > startY && r.posY <= endY) + && r.posY + r.sizeY > startY && r.posY <= endY) ret.Add(r); } } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/DispatchRegionInfo.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/DispatchRegionInfo.cs index 3fdcdf085af..53b3a19edc1 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/DispatchRegionInfo.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/DispatchRegionInfo.cs @@ -31,7 +31,8 @@ public void DispatchRegionInfo(IOSHttpRequest request, IOSHttpResponse response, return; } - if(map == map.Count < 3) + // Ensure we have a valid map with the expected minimum number of entries + if (map == null || map.Count < 3) { response.StatusCode = (int)HttpStatusCode.BadRequest; return; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs b/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs index a77e3fec1d7..8deab623389 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EstateAccess.cs @@ -65,8 +65,13 @@ public void Initialise(IConfigSource pSource) return; m_capUrl = config.GetString("Cap_EstateAccess", string.Empty); - if (!String.IsNullOrEmpty(m_capUrl) && m_capUrl.Equals("localhost")) + // enable when configured (non-empty and not explicitly false/0) + if (!String.IsNullOrEmpty(m_capUrl) && + !m_capUrl.Equals("false", StringComparison.OrdinalIgnoreCase) && + m_capUrl != "0") + { m_Enabled = true; + } } public void AddRegion(Scene scene) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs index 56e840b0e00..dfe5cf310bb 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ServerReleaseNotesModule.cs @@ -67,8 +67,14 @@ public void Initialise(IConfigSource source) return; string capURL = config.GetString("Cap_ServerReleaseNotes", string.Empty); - if (string.IsNullOrEmpty(capURL) || capURL != "localhost") + // If capability not configured or explicitly turned off, leave disabled + if (string.IsNullOrEmpty(capURL) || + capURL.Equals("false", StringComparison.OrdinalIgnoreCase) || + capURL == "0") + { + m_log.DebugFormat("[ServerReleaseNotesModule]: Cap_ServerReleaseNotes not enabled in config"); return; + } config = source.Configs["ServerReleaseNotes"]; if (config == null) @@ -76,16 +82,19 @@ public void Initialise(IConfigSource source) m_ServerReleaseNotesURL = config.GetString("ServerReleaseNotesURL", m_ServerReleaseNotesURL); if (string.IsNullOrEmpty(m_ServerReleaseNotesURL)) + { + m_log.Error("[ServerReleaseNotesModule]: ServerReleaseNotesURL not configured. Cap disabled."); return; + } - Uri dummy; - if(!Uri.TryCreate(m_ServerReleaseNotesURL,UriKind.Absolute, out dummy)) + if (!Uri.IsWellFormedUriString(m_ServerReleaseNotesURL, UriKind.Absolute)) { - m_log.Error("[Cap_ServerReleaseNotes]: Invalid ServerReleaseNotesURL. Cap Disabled"); + m_log.ErrorFormat("[ServerReleaseNotesModule]: Invalid ServerReleaseNotesURL '{0}'. Cap Disabled", m_ServerReleaseNotesURL); return; } m_enabled = true; + m_log.InfoFormat("[ServerReleaseNotesModule]: Enabled. Redirecting ServerReleaseNotes cap to {0}", m_ServerReleaseNotesURL); } public void AddRegion(Scene scene) diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs index 1079e101ddd..6f94f1f63e1 100644 --- a/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs +++ b/OpenSim/Services/Connectors/MapImage/MapImageServicesConnector.cs @@ -26,21 +26,14 @@ */ using log4net; -using System; -using System.Collections.Generic; -using System.IO; using System.Net; using System.Reflection; using Nini.Config; using OpenSim.Framework; -using OpenSim.Framework.Console; - -using OpenSim.Framework.ServiceAuth; using OpenSim.Server.Base; using OpenSim.Services.Interfaces; using OpenMetaverse; -using OpenMetaverse.StructuredData; namespace OpenSim.Services.Connectors { @@ -105,12 +98,12 @@ public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason) } else { + // Do not include SCOPE when it's zero reqString = ServerUtils.BuildQueryString( new Dictionary() { {"X" , x.ToString() }, - {"Y" , y.ToString() }, - { "SCOPE" , scopeID.ToString() }, + {"Y" , y.ToString() } } ); } @@ -118,7 +111,7 @@ public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason) try { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/map", reqString, 10, null, false); - if (reply.Length > 0) + if (!string.IsNullOrEmpty(reply)) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); if(replyData.TryGetValue("Result", out object resultobj)) @@ -133,17 +126,17 @@ public bool RemoveMapTile(int x, int y, UUID scopeID, out string reason) return true; else if (res.Equals("failure", StringComparison.InvariantCultureIgnoreCase)) { - reason = replyData["Message"].ToString(); + reason = replyData.TryGetValue("Message", out var value) ? value.ToString() : ""; m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RemoveMapTile failed: {0}", reason); return false; } m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RemoveMapTile unknown result field contents"); return false; } - } - else - { - m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RemoveMapTile reply data does not contain result field"); + else + { + m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RemoveMapTile reply data does not contain result field"); + } } } catch (Exception e) @@ -188,7 +181,7 @@ public bool AddMapTile(int x, int y, byte[] jpgData, UUID scopeID, out string re try { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/map", reqString, 10, m_Auth, false); - if (reply.Length > 0) + if (!string.IsNullOrEmpty(reply)) { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); if (replyData.TryGetValue("Result", out object resultobj)) @@ -203,7 +196,7 @@ public bool AddMapTile(int x, int y, byte[] jpgData, UUID scopeID, out string re return true; else if (res.Equals("failure", StringComparison.InvariantCultureIgnoreCase)) { - reason = replyData["Message"].ToString(); + reason = replyData.TryGetValue("Message", out var value) ? value.ToString() : ""; m_log.DebugFormat("[MAP IMAGE CONNECTOR]: AddMapTile failed: {0}", reason); return false; } @@ -231,9 +224,7 @@ public bool AddMapTile(int x, int y, byte[] jpgData, UUID scopeID, out string re public byte[] GetMapTile(string fileName, UUID scopeID, out string format) { - format = string.Empty; - new Exception("GetMapTile method not Implemented"); - return null; + throw new Exception("GetMapTile method not Implemented"); } } }