public void Deny_Unrestricted () { HttpCookieCollection jar = new HttpCookieCollection (); jar.Add (biscuit); jar.CopyTo (new object[1], 0); Assert.IsNull (jar.GetKey (0), "GetKey"); jar.Remove ("chocolat"); jar.Set (biscuit); Assert.IsNotNull (jar.Get (0), "Get(int)"); Assert.IsNull (jar.Get ("chocolat"), "Get(string)"); Assert.IsNotNull (jar[0], "this[int]"); Assert.IsNull (jar["chocolat"], "this[string]"); Assert.AreEqual (1, jar.AllKeys.Length, "AllKeys"); jar.Clear (); }
private void ValidateCookieCollection(HttpCookieCollection cc) { if (GranularValidationEnabled) { // Granular request validation is enabled - validate collection entries only as they're accessed. cc.EnableGranularValidation((key, value) => ValidateString(value, key, RequestValidationSource.Cookies)); } else { // Granular request validation is disabled - eagerly validate all collection entries. int c = cc.Count; for (int i = 0; i < c; i++) { String key = cc.GetKey(i); String val = cc.Get(i).Value; if (!String.IsNullOrEmpty(val)) ValidateString(val, key, RequestValidationSource.Cookies); } } }
private void ValidateCookieCollection(HttpCookieCollection cc) { int count = cc.Count; for (int i = 0; i < count; i++) { string key = cc.GetKey(i); string str2 = cc.Get(i).Value; if (!string.IsNullOrEmpty(str2)) { this.ValidateString(str2, key, RequestValidationSource.Cookies); } } }
/// <summary> /// Servers the variables. /// </summary> /// <param name="collection">The collection.</param> /// <returns></returns> private static string GenerateCookieKeyPairs(HttpCookieCollection collection) { StringBuilder builder = new StringBuilder(); for (int index = 0; index < collection.Count; index++) { builder.AppendLine(string.Format("{0}:{1}", collection.GetKey(index), collection[index])); } return builder.ToString(); }