aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Base
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs71
1 files changed, 57 insertions, 14 deletions
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 0964caa..a5d28a4 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -160,9 +160,9 @@ namespace OpenSim.Server.Base
160 } 160 }
161 } 161 }
162 162
163 public static Dictionary<string, string> ParseQueryString(string query) 163 public static Dictionary<string, object> ParseQueryString(string query)
164 { 164 {
165 Dictionary<string, string> result = new Dictionary<string, string>(); 165 Dictionary<string, object> result = new Dictionary<string, object>();
166 string[] terms = query.Split(new char[] {'&'}); 166 string[] terms = query.Split(new char[] {'&'});
167 167
168 if (terms.Length == 0) 168 if (terms.Length == 0)
@@ -180,33 +180,76 @@ namespace OpenSim.Server.Base
180 if (elems.Length > 1) 180 if (elems.Length > 1)
181 value = System.Web.HttpUtility.UrlDecode(elems[1]); 181 value = System.Web.HttpUtility.UrlDecode(elems[1]);
182 182
183 result[name] = value; 183 if (name.EndsWith("[]"))
184 {
185 if (result.ContainsKey(name))
186 {
187 if (!(result[name] is List<string>))
188 continue;
189
190 List<string> l = (List<string>)result[name];
191
192 l.Add(value);
193 }
194 else
195 {
196 List<string> newList = new List<string>();
197
198 newList.Add(value);
199
200 result[name] = newList;
201 }
202 }
203 else
204 {
205 if (!result.ContainsKey(name))
206 result[name] = value;
207 }
184 } 208 }
185 209
186 return result; 210 return result;
187 } 211 }
188 212
189 public static string BuildQueryString(Dictionary<string, string> data) 213 public static string BuildQueryString(Dictionary<string, object> data)
190 { 214 {
191 string qstring = String.Empty; 215 string qstring = String.Empty;
192 216
193 foreach (KeyValuePair<string, string> kvp in data) 217 string part;
218
219 foreach (KeyValuePair<string, object> kvp in data)
194 { 220 {
195 string part; 221 if (kvp.Value is List<string>)
196 if (kvp.Value != String.Empty)
197 { 222 {
198 part = System.Web.HttpUtility.UrlEncode(kvp.Key) + 223 List<string> l = (List<String>)kvp.Value;
199 "=" + System.Web.HttpUtility.UrlEncode(kvp.Value); 224
225 foreach (string s in l)
226 {
227 part = System.Web.HttpUtility.UrlEncode(kvp.Key) +
228 "[]=" + System.Web.HttpUtility.UrlEncode(s);
229
230 if (qstring != String.Empty)
231 qstring += "&";
232
233 qstring += part;
234 }
200 } 235 }
201 else 236 else
202 { 237 {
203 part = System.Web.HttpUtility.UrlEncode(kvp.Key); 238 if (kvp.Value.ToString() != String.Empty)
204 } 239 {
240 part = System.Web.HttpUtility.UrlEncode(kvp.Key) +
241 "=" + System.Web.HttpUtility.UrlEncode(kvp.Value.ToString());
242 }
243 else
244 {
245 part = System.Web.HttpUtility.UrlEncode(kvp.Key);
246 }
205 247
206 if (qstring != String.Empty) 248 if (qstring != String.Empty)
207 qstring += "&"; 249 qstring += "&";
208 250
209 qstring += part; 251 qstring += part;
252 }
210 } 253 }
211 254
212 return qstring; 255 return qstring;