From f0fd15ccc9c5f8d30d8e7e3953e1779f9f4563c0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 20 Dec 2017 18:20:26 +0000 Subject: [PATCH 1/3] add missing entry on prebuid.xml for mutelist service --- prebuild.xml | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/prebuild.xml b/prebuild.xml index f39cbde24e..0241fb397b 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -98,7 +98,6 @@ - @@ -1095,6 +1094,34 @@ + + + + ../../../bin/ + + + + + ../../../bin/ + + + + ../../../bin/ + + + + + + + + + + + + + + + @@ -1130,6 +1157,38 @@ + + + + ../../../bin/ + + + + + ../../../bin/ + + + + ../../../bin/ + + + + + + + + + + + + + + + + + + + From 803289877307ce0016627f58af382b68a1905327 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 30 Dec 2017 15:28:26 +0000 Subject: [PATCH 2/3] mantis 8271: work around missing encoding of estate bans on the pseudo url encode used on POST, without changing the xml also used elsewhere. Possible this can be used in other case --- OpenSim/Framework/EstateSettings.cs | 43 ++++++++-- OpenSim/Server/Base/ServerUtils.cs | 128 ++++++++++++++++++---------- 2 files changed, 117 insertions(+), 54 deletions(-) diff --git a/OpenSim/Framework/EstateSettings.cs b/OpenSim/Framework/EstateSettings.cs index 7134cbf825..8c8270aa9b 100644 --- a/OpenSim/Framework/EstateSettings.cs +++ b/OpenSim/Framework/EstateSettings.cs @@ -572,14 +572,41 @@ namespace OpenSim.Framework // EstateBans are special if (map.ContainsKey("EstateBans")) - { - var banData = ((Dictionary)map["EstateBans"]).Values; - EstateBan[] bans = new EstateBan[banData.Count]; - int b = 0; - foreach (Dictionary ban in banData) - bans[b++] = new EstateBan(ban); - PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance); - bansProperty.SetValue(this, bans, null); + { + if(map["EstateBans"] is string) + { + // JSON encoded bans map + Dictionary bdata = new Dictionary(); + try + { + // bypass libovm, we dont need even more useless high level maps + // this should only be called once.. but no problem, i hope + // (other uses may need more..) + LitJson.JsonMapper.RegisterImporter((input) => new UUID(input)); + bdata = LitJson.JsonMapper.ToObject>((string)map["EstateBans"]); + } + // catch(Exception e) + catch + { + return; + } + EstateBan[] jbans = new EstateBan[bdata.Count]; + bdata.Values.CopyTo(jbans,0); + + PropertyInfo jbansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance); + jbansProperty.SetValue(this, jbans, null); + } + else + { + var banData = ((Dictionary)map["EstateBans"]).Values; + EstateBan[] bans = new EstateBan[banData.Count]; + + int b = 0; + foreach (Dictionary ban in banData) + bans[b++] = new EstateBan(ban); + PropertyInfo bansProperty = this.GetType().GetProperty("EstateBans", BindingFlags.Public | BindingFlags.Instance); + bansProperty.SetValue(this, bans, null); + } } } } diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index aff6b4fc7a..9fd613fc04 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -39,7 +39,7 @@ using OpenMetaverse; using Mono.Addins; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Framework.Servers; - +using OpenMetaverse.StructuredData; // LitJson is hidden on this [assembly:AddinRoot("Robust", OpenSim.VersionInfo.VersionNumber)] namespace OpenSim.Server.Base @@ -326,50 +326,63 @@ namespace OpenSim.Server.Base } public static Dictionary ParseQueryString(string query) - { - Dictionary result = new Dictionary(); + { string[] terms = query.Split(new char[] {'&'}); - if (terms.Length == 0) - return result; + int nterms = terms.Length; + if (nterms == 0) + return new Dictionary(); - foreach (string t in terms) + Dictionary result = new Dictionary(nterms); + string name; + + for(int i = 0; i < nterms; ++i) { - string[] elems = t.Split(new char[] {'='}); + string[] elems = terms[i].Split(new char[] {'='}); + if (elems.Length == 0) continue; - string name = System.Web.HttpUtility.UrlDecode(elems[0]); - string value = String.Empty; + if(String.IsNullOrWhiteSpace(elems[0])) + continue; - if (elems.Length > 1) - value = System.Web.HttpUtility.UrlDecode(elems[1]); + name = System.Web.HttpUtility.UrlDecode(elems[0]); if (name.EndsWith("[]")) { - string cleanName = name.Substring(0, name.Length - 2); - if (result.ContainsKey(cleanName)) + name = name.Substring(0, name.Length - 2); + if(String.IsNullOrWhiteSpace(name)) + continue; + if (result.ContainsKey(name)) { - if (!(result[cleanName] is List)) + if (!(result[name] is List)) continue; - List l = (List)result[cleanName]; - - l.Add(value); + List l = (List)result[name]; + if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1])) + l.Add(System.Web.HttpUtility.UrlDecode(elems[1])); + else + l.Add(String.Empty); } else { List newList = new List(); - - newList.Add(value); - - result[cleanName] = newList; + if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1])) + newList.Add(System.Web.HttpUtility.UrlDecode(elems[1])); + else + newList.Add(String.Empty); + result[name] = newList; } } else { if (!result.ContainsKey(name)) - result[name] = value; + { + if (elems.Length > 1 && !String.IsNullOrWhiteSpace(elems[1])) + result[name] = System.Web.HttpUtility.UrlDecode(elems[1]); + else + result[name] = String.Empty; + } } } @@ -378,47 +391,70 @@ namespace OpenSim.Server.Base public static string BuildQueryString(Dictionary data) { - string qstring = String.Empty; + // this is not conform to html url encoding + // can only be used on Body of POST or PUT + StringBuilder sb = new StringBuilder(4096); - string part; + string pvalue; foreach (KeyValuePair kvp in data) { if (kvp.Value is List) { List l = (List)kvp.Value; - - foreach (string s in l) + int llen = l.Count; + string nkey = System.Web.HttpUtility.UrlEncode(kvp.Key); + for(int i = 0; i < llen; ++i) { - part = System.Web.HttpUtility.UrlEncode(kvp.Key) + - "[]=" + System.Web.HttpUtility.UrlEncode(s); - - if (qstring != String.Empty) - qstring += "&"; - - qstring += part; + if (sb.Length != 0) + sb.Append("&"); + sb.Append(nkey); + sb.Append("[]="); + sb.Append(System.Web.HttpUtility.UrlEncode(l[i])); } } + else if(kvp.Value is Dictionary) + { + // encode complex structures as JSON + // needed for estate bans with the encoding used on xml + // encode can be here because object does contain the structure information + // but decode needs to be on estateSettings (or other user) + string js; + try + { + // bypass libovm, we dont need even more useless high level maps + // this should only be called once.. but no problem, i hope + // (other uses may need more..) + LitJson.JsonMapper.RegisterExporter((uuid, writer) => writer.Write(uuid.ToString()) ); + js = LitJson.JsonMapper.ToJson(kvp.Value); + } + // catch(Exception e) + catch + { + continue; + } + if (sb.Length != 0) + sb.Append("&"); + sb.Append(System.Web.HttpUtility.UrlEncode(kvp.Key)); + sb.Append("="); + sb.Append(System.Web.HttpUtility.UrlEncode(js)); + } else { - if (kvp.Value.ToString() != String.Empty) + if (sb.Length != 0) + sb.Append("&"); + sb.Append(System.Web.HttpUtility.UrlEncode(kvp.Key)); + + pvalue = kvp.Value.ToString(); + if (!String.IsNullOrEmpty(pvalue)) { - part = System.Web.HttpUtility.UrlEncode(kvp.Key) + - "=" + System.Web.HttpUtility.UrlEncode(kvp.Value.ToString()); + sb.Append("="); + sb.Append(System.Web.HttpUtility.UrlEncode(pvalue)); } - else - { - part = System.Web.HttpUtility.UrlEncode(kvp.Key); - } - - if (qstring != String.Empty) - qstring += "&"; - - qstring += part; } } - return qstring; + return sb.ToString(); } public static string BuildXmlResponse(Dictionary data) From a7803409f6aae704375e7582aab7cbe7f3e17283 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 30 Dec 2017 15:46:32 +0000 Subject: [PATCH 3/3] clean some extra space chars --- OpenSim/Server/Base/ServerUtils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 9fd613fc04..d0043ba7d9 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -326,7 +326,7 @@ namespace OpenSim.Server.Base } public static Dictionary ParseQueryString(string query) - { + { string[] terms = query.Split(new char[] {'&'}); int nterms = terms.Length;