// HttpValueCollection used to call UrlEncodeUnicode in its ToString method, so we should continue to // do so for back-compat. The result of ToString is not used to make a security decision, so this // code path is "safe". internal static string UrlEncodeForToString(string input) { #pragma warning disable 618 // [Obsolete] return(HttpUtility.UrlEncodeUnicode(input)); #pragma warning restore 618 }
// // HttpValueCollection overrides // internal override string ToString(bool urlencoded) { Populate(); StringBuilder s = new StringBuilder(); int n = Count; String key, value; for (int i = 0; i < n; i++) { if (i > 0) { s.Append('&'); } key = GetKey(i); if (urlencoded) { key = HttpUtility.UrlEncodeUnicode(key); } s.Append(key); s.Append('='); value = Get(i); if (urlencoded) { value = HttpUtility.UrlEncodeUnicode(value); } s.Append(value); } return(s.ToString()); }
internal override string ToString(bool urlencoded) { this.Populate(); StringBuilder builder = new StringBuilder(); int count = this.Count; for (int i = 0; i < count; i++) { if (i > 0) { builder.Append('&'); } string key = this.GetKey(i); if (urlencoded) { key = HttpUtility.UrlEncodeUnicode(key); } builder.Append(key); builder.Append('='); string str = this.Get(i); if (urlencoded) { str = HttpUtility.UrlEncodeUnicode(str); } builder.Append(str); } return(builder.ToString()); }
internal virtual String ToString(bool urlencoded) { StringBuilder s = new StringBuilder(); int n = Count; String key, keyPrefix, item; for (int i = 0; i < n; i++) { key = GetKey(i); if (urlencoded) { key = HttpUtility.UrlEncodeUnicode(key); } keyPrefix = (key != null && key.Length > 0) ? (key + "=") : ""; ArrayList values = (ArrayList)BaseGet(i); int numValues = (values != null) ? values.Count : 0; if (i > 0) { s.Append('&'); } if (numValues == 1) { s.Append(keyPrefix); item = (String)values[0]; if (urlencoded) { item = HttpUtility.UrlEncodeUnicode(item); } s.Append(item); } else if (numValues == 0) { s.Append(keyPrefix); } else { for (int j = 0; j < numValues; j++) { if (j > 0) { s.Append('&'); } s.Append(keyPrefix); item = (String)values[j]; if (urlencoded) { item = HttpUtility.UrlEncodeUnicode(item); } s.Append(item); } } } return(s.ToString()); }
// HttpValueCollection used to call UrlEncodeUnicode in its ToString method, so we should continue to // do so for back-compat. The result of ToString is not used to make a security decision, so this // code path is "safe". internal static string UrlEncodeForToString(string input) { if (AppSettings.DontUsePercentUUrlEncoding) { // DevDiv #762975: <form action> and other similar URLs are mangled since we use non-standard %uXXXX encoding. // We need to use standard UTF8 encoding for modern browsers to understand the URLs. return(HttpUtility.UrlEncode(input)); } else { #pragma warning disable 618 // [Obsolete] return(HttpUtility.UrlEncodeUnicode(input)); #pragma warning restore 618 } }
internal virtual string ToString(bool urlencoded, IDictionary excludeKeys) { int count = this.Count; if (count == 0) { return(string.Empty); } StringBuilder builder = new StringBuilder(); bool flag = (excludeKeys != null) && (excludeKeys["__VIEWSTATE"] != null); for (int i = 0; i < count; i++) { string key = this.GetKey(i); if (((!flag || (key == null)) || !key.StartsWith("__VIEWSTATE", StringComparison.Ordinal)) && (((excludeKeys == null) || (key == null)) || (excludeKeys[key] == null))) { string str3; if (urlencoded) { key = HttpUtility.UrlEncodeUnicode(key); } string str2 = (key != null) ? (key + "=") : string.Empty; ArrayList list = (ArrayList)base.BaseGet(i); int num3 = (list != null) ? list.Count : 0; if (builder.Length > 0) { builder.Append('&'); } if (num3 == 1) { builder.Append(str2); str3 = (string)list[0]; if (urlencoded) { str3 = HttpUtility.UrlEncodeUnicode(str3); } builder.Append(str3); } else if (num3 == 0) { builder.Append(str2); } else { for (int j = 0; j < num3; j++) { if (j > 0) { builder.Append('&'); } builder.Append(str2); str3 = (string)list[j]; if (urlencoded) { str3 = HttpUtility.UrlEncodeUnicode(str3); } builder.Append(str3); } } } } return(builder.ToString()); }