diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs index 413a078063..a5d28a413d 100644 --- a/OpenSim/Server/Base/ServerUtils.cs +++ b/OpenSim/Server/Base/ServerUtils.cs @@ -180,7 +180,31 @@ namespace OpenSim.Server.Base if (elems.Length > 1) value = System.Web.HttpUtility.UrlDecode(elems[1]); - result[name] = value; + if (name.EndsWith("[]")) + { + if (result.ContainsKey(name)) + { + if (!(result[name] is List)) + continue; + + List l = (List)result[name]; + + l.Add(value); + } + else + { + List newList = new List(); + + newList.Add(value); + + result[name] = newList; + } + } + else + { + if (!result.ContainsKey(name)) + result[name] = value; + } } return result; @@ -190,23 +214,42 @@ namespace OpenSim.Server.Base { string qstring = String.Empty; + string part; + foreach (KeyValuePair kvp in data) { - string part; - if (kvp.Value.ToString() != String.Empty) + if (kvp.Value is List) { - part = System.Web.HttpUtility.UrlEncode(kvp.Key) + - "=" + System.Web.HttpUtility.UrlEncode(kvp.Value.ToString()); + List l = (List)kvp.Value; + + foreach (string s in l) + { + part = System.Web.HttpUtility.UrlEncode(kvp.Key) + + "[]=" + System.Web.HttpUtility.UrlEncode(s); + + if (qstring != String.Empty) + qstring += "&"; + + qstring += part; + } } else { - part = System.Web.HttpUtility.UrlEncode(kvp.Key); + if (kvp.Value.ToString() != String.Empty) + { + part = System.Web.HttpUtility.UrlEncode(kvp.Key) + + "=" + System.Web.HttpUtility.UrlEncode(kvp.Value.ToString()); + } + else + { + part = System.Web.HttpUtility.UrlEncode(kvp.Key); + } + + if (qstring != String.Empty) + qstring += "&"; + + qstring += part; } - - if (qstring != String.Empty) - qstring += "&"; - - qstring += part; } return qstring;