From 71f7bfc2ff195106254712654fdd549ea9f2a3e3 Mon Sep 17 00:00:00 2001 From: Talun Date: Thu, 24 Jan 2013 21:08:57 +0000 Subject: Mantis 6508 llHTTPResponse body is incorrectly interpreted by IE This patch html escapes responses going to IE so that they cannot be interpreted as HTML if the response type is "text/plain". This has no effect if the reponse type has been set to "text/html" by osSetContentType Signed-off-by: nebadon --- .../Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index a654477..be617a5 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -328,8 +328,22 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp if (m_RequestMap.ContainsKey(request)) { UrlData urlData = m_RequestMap[request]; + string responseBody = body; + if (urlData.requests[request].responseType.Equals("text/plain")) + { + string value; + if (urlData.requests[request].headers.TryGetValue("user-agent", out value)) + { + if (value != null && value.IndexOf("MSIE") >= 0) + { + // wrap the html escaped response if the target client is IE + // It ignores "text/plain" if the body is html + responseBody = "" + System.Web.HttpUtility.HtmlEncode(body) + ""; + } + } + } urlData.requests[request].responseCode = status; - urlData.requests[request].responseBody = body; + urlData.requests[request].responseBody = responseBody; //urlData.requests[request].ev.Set(); urlData.requests[request].requestDone =true; } -- cgit v1.1 From f557d7e82821c931c6ca2faf97c668fa94cacfb0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Jan 2013 01:48:31 +0000 Subject: Add basic JsonCreateStore() regression test --- .../CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index f6e1d39..6bf50d2 100644 --- a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -41,7 +41,7 @@ using System.Linq.Expressions; namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms { [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] - class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms + public class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From 71862f34b6e97e19fceefd9ccb813ce09ef0a0c3 Mon Sep 17 00:00:00 2001 From: teravus Date: Thu, 14 Feb 2013 18:52:11 -0500 Subject: * Handle null check on configs in module startup so that the the code can be run on 'stop on handled and unhandled null reference exceptions' mode without pausing during startup a bunch of times. I don't think exceptions were really meant for replacing a single if statement... --- .../Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs index 385f5ad..cbffca7 100644 --- a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs @@ -111,13 +111,15 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC m_rpcPending = new Dictionary(); m_rpcPendingResponses = new Dictionary(); m_pendingSRDResponses = new Dictionary(); - - try - { - m_remoteDataPort = config.Configs["XMLRPC"].GetInt("XmlRpcPort", m_remoteDataPort); - } - catch (Exception) + if (config.Configs["XMLRPC"] != null) { + try + { + m_remoteDataPort = config.Configs["XMLRPC"].GetInt("XmlRpcPort", m_remoteDataPort); + } + catch (Exception) + { + } } } -- cgit v1.1 From b8a7c8b26f3005eed5b161c37509b06b1d604967 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 26 Feb 2013 23:36:36 +0000 Subject: Add regression test for llRequestUrl() --- .../CoreModules/Scripting/LSLHttp/UrlModule.cs | 37 ++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index be617a5..79e633f 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -122,15 +122,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp /// private int m_TotalUrls = 100; - private uint https_port = 0; + private uint m_HttpsPort = 0; private IHttpServer m_HttpServer = null; private IHttpServer m_HttpsServer = null; - private string m_ExternalHostNameForLSL = ""; - public string ExternalHostNameForLSL - { - get { return m_ExternalHostNameForLSL; } - } + public string ExternalHostNameForLSL { get; private set; } public Type ReplaceableInterface { @@ -144,11 +140,20 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public void Initialise(IConfigSource config) { - m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName); - bool ssl_enabled = config.Configs["Network"].GetBoolean("https_listener",false); + IConfig networkConfig = config.Configs["Network"]; + + if (networkConfig != null) + { + ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", null); + + bool ssl_enabled = config.Configs["Network"].GetBoolean("https_listener", false); + + if (ssl_enabled) + m_HttpsPort = (uint)config.Configs["Network"].GetInt("https_port", (int)m_HttpsPort); + } - if (ssl_enabled) - https_port = (uint) config.Configs["Network"].GetInt("https_port",0); + if (ExternalHostNameForLSL == null) + ExternalHostNameForLSL = System.Environment.MachineName; IConfig llFunctionsConfig = config.Configs["LL-Functions"]; @@ -169,9 +174,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp m_HttpServer = MainServer.Instance; // // We can use the https if it is enabled - if (https_port > 0) + if (m_HttpsPort > 0) { - m_HttpsServer = MainServer.GetHttpServer(https_port); + m_HttpsServer = MainServer.GetHttpServer(m_HttpsPort); } } @@ -209,7 +214,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; } - string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; + string url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; @@ -254,7 +259,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; } - string url = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; + string url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + "/lslhttps/" + urlcode.ToString() + "/"; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; @@ -579,9 +584,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp string url; if (is_ssl) - url = "https://" + m_ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp; + url = "https://" + ExternalHostNameForLSL + ":" + m_HttpsServer.Port.ToString() + uri_tmp; else - url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp; + url = "http://" + ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp; // Avoid a race - the request URL may have been released via llRequestUrl() whilst this // request was being processed. -- cgit v1.1 From 80c19b7cac52a57fd04966169c657400aeee3de8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 27 Feb 2013 00:21:02 +0000 Subject: Make sure we dispose of WebResponse, StreamReader and Stream in various places where we were not already. --- .../Scripting/VectorRender/VectorRenderModule.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index 689e8a7..f04fabe 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -838,13 +838,17 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender try { WebRequest request = HttpWebRequest.Create(url); -//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used. -//Ckrinke Stream str = null; - HttpWebResponse response = (HttpWebResponse)(request).GetResponse(); - if (response.StatusCode == HttpStatusCode.OK) + + using (HttpWebResponse response = (HttpWebResponse)(request).GetResponse()) { - Bitmap image = new Bitmap(response.GetResponseStream()); - return image; + if (response.StatusCode == HttpStatusCode.OK) + { + using (Stream s = response.GetResponseStream()) + { + Bitmap image = new Bitmap(s); + return image; + } + } } } catch { } -- cgit v1.1 From 59bd099b0385cc79bba751e168ef26c923c9f003 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 27 Feb 2013 20:12:58 +0000 Subject: Add regression test for llReleaseUrl() (and for llRequestUrl) Forgot to add file for llRequestUrl() test in commit b8a7c8b --- .../CoreModules/Scripting/LSLHttp/UrlModule.cs | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 79e633f..c9cd412 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -117,17 +117,22 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp /// private Dictionary m_UrlMap = new Dictionary(); - /// - /// Maximum number of external urls that can be set up by this module. - /// - private int m_TotalUrls = 100; - private uint m_HttpsPort = 0; private IHttpServer m_HttpServer = null; private IHttpServer m_HttpsServer = null; public string ExternalHostNameForLSL { get; private set; } + /// + /// The default maximum number of urls + /// + public const int DefaultTotalUrls = 100; + + /// + /// Maximum number of external urls that can be set up by this module. + /// + public int TotalUrls { get; set; } + public Type ReplaceableInterface { get { return null; } @@ -158,7 +163,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp IConfig llFunctionsConfig = config.Configs["LL-Functions"]; if (llFunctionsConfig != null) - m_TotalUrls = llFunctionsConfig.GetInt("max_external_urls_per_simulator", m_TotalUrls); + TotalUrls = llFunctionsConfig.GetInt("max_external_urls_per_simulator", DefaultTotalUrls); + else + TotalUrls = DefaultTotalUrls; } public void PostInitialise() @@ -209,7 +216,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp lock (m_UrlMap) { - if (m_UrlMap.Count >= m_TotalUrls) + if (m_UrlMap.Count >= TotalUrls) { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; @@ -254,7 +261,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp lock (m_UrlMap) { - if (m_UrlMap.Count >= m_TotalUrls) + if (m_UrlMap.Count >= TotalUrls) { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; @@ -382,7 +389,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public int GetFreeUrls() { lock (m_UrlMap) - return m_TotalUrls - m_UrlMap.Count; + return TotalUrls - m_UrlMap.Count; } public void ScriptRemoved(UUID itemID) -- cgit v1.1 From b7216f4daffca6dad4049c84982beca6dca9b094 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 13 Mar 2013 00:46:17 +0000 Subject: minor: save some commented out log lines which will be useful again in future debugging of VectorRenderModule --- .../Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index f04fabe..4cecd85 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -516,6 +516,9 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender foreach (string line in GetLines(data, dataDelim)) { string nextLine = line.Trim(); + +// m_log.DebugFormat("[VECTOR RENDER MODULE]: Processing line '{0}'", nextLine); + //replace with switch, or even better, do some proper parsing if (nextLine.StartsWith("MoveTo")) { @@ -829,6 +832,8 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender float y = Convert.ToSingle(yVal, CultureInfo.InvariantCulture); PointF point = new PointF(x, y); points[i / 2] = point; + +// m_log.DebugFormat("[VECTOR RENDER MODULE]: Got point {0}", points[i / 2]); } } } -- cgit v1.1 From cbc9ae898c474295567532c668644d09b698d59b Mon Sep 17 00:00:00 2001 From: Kevin Cozens Date: Wed, 27 Mar 2013 17:26:17 -0400 Subject: Added missing functionality (mainly custom headers) to llHTTPRequest. --- .../Scripting/HttpRequest/ScriptsHttpRequests.cs | 73 +++++++++++++++++++--- 1 file changed, 64 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/CoreModules/Scripting') diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index a676971..c2e37c4 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -187,6 +187,45 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest case (int)HttpRequestConstants.HTTP_VERIFY_CERT: htc.HttpVerifyCert = (int.Parse(parms[i + 1]) != 0); break; + + case (int)HttpRequestConstants.HTTP_VERBOSE_THROTTLE: + + // TODO implement me + break; + + case (int)HttpRequestConstants.HTTP_CUSTOM_HEADER: + //Parameters are in pairs and custom header takes + //arguments in pairs so adjust for header marker. + ++i; + + //Maximum of 8 headers are allowed based on the + //Second Life documentation for llHTTPRequest. + for (int count = 1; count <= 8; ++count) + { + //Not enough parameters remaining for a header? + if (parms.Length - i < 2) + break; + + //Have we reached the end of the list of headers? + //End is marked by a string with a single digit. + //We already know we have at least one parameter + //so it is safe to do this check at top of loop. + if (Char.IsDigit(parms[i][0])) + break; + + if (htc.HttpCustomHeaders == null) + htc.HttpCustomHeaders = new List(); + + htc.HttpCustomHeaders.Add(parms[i]); + htc.HttpCustomHeaders.Add(parms[i+1]); + + i += 2; + } + break; + + case (int)HttpRequestConstants.HTTP_PRAGMA_NO_CACHE: + htc.HttpPragmaNoCache = (int.Parse(parms[i + 1]) != 0); + break; } } } @@ -328,9 +367,12 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest // public const int HTTP_METHOD = 0; // public const int HTTP_MIMETYPE = 1; // public const int HTTP_VERIFY_CERT = 3; + // public const int HTTP_VERBOSE_THROTTLE = 4; + // public const int HTTP_CUSTOM_HEADER = 5; + // public const int HTTP_PRAGMA_NO_CACHE = 6; private bool _finished; public bool Finished - { + { get { return _finished; } } // public int HttpBodyMaxLen = 2048; // not implemented @@ -340,11 +382,14 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest public string HttpMIMEType = "text/plain;charset=utf-8"; public int HttpTimeout; public bool HttpVerifyCert = true; + //public bool HttpVerboseThrottle = true; // not implemented + public List HttpCustomHeaders = null; + public bool HttpPragmaNoCache = true; private Thread httpThread; // Request info private UUID _itemID; - public UUID ItemID + public UUID ItemID { get { return _itemID; } set { _itemID = value; } @@ -360,7 +405,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest public string proxyexcepts; public string OutboundBody; private UUID _reqID; - public UUID ReqID + public UUID ReqID { get { return _reqID; } set { _reqID = value; } @@ -401,7 +446,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest Request.Method = HttpMethod; Request.ContentType = HttpMIMEType; - if(!HttpVerifyCert) + if (!HttpVerifyCert) { // We could hijack Connection Group Name to identify // a desired security exception. But at the moment we'll use a dummy header instead. @@ -412,14 +457,24 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest // { // Request.ConnectionGroupName="Verify"; // } - if (proxyurl != null && proxyurl.Length > 0) + if (!HttpPragmaNoCache) + { + Request.Headers.Add("Pragma", "no-cache"); + } + if (HttpCustomHeaders != null) { - if (proxyexcepts != null && proxyexcepts.Length > 0) + for (int i = 0; i < HttpCustomHeaders.Count; i += 2) + Request.Headers.Add(HttpCustomHeaders[i], + HttpCustomHeaders[i+1]); + } + if (proxyurl != null && proxyurl.Length > 0) + { + if (proxyexcepts != null && proxyexcepts.Length > 0) { string[] elist = proxyexcepts.Split(';'); Request.Proxy = new WebProxy(proxyurl, true, elist); - } - else + } + else { Request.Proxy = new WebProxy(proxyurl, true); } @@ -432,7 +487,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest Request.Headers[entry.Key] = entry.Value; // Encode outbound data - if (OutboundBody.Length > 0) + if (OutboundBody.Length > 0) { byte[] data = Util.UTF8.GetBytes(OutboundBody); -- cgit v1.1