/// <summary> /// Adds a token to the sandbox-token-list. /// </summary> /// <param name="token">The token.</param> /// <exception cref="System.FormatException"> /// For more information see: http://www.w3.org/TR/CSP2/#sandbox-token /// </exception> public void AddToken(string token) { token.MustNotNull("token"); token.MustNotBeWhiteSpaceOrEmpty("token"); if (mTokens.Contains(token)) { return; } if (!Rfc7230Utility.IsToken(token)) { const string msg = "Token value '{0}' is invalid.{1}" + "Valid tokens: allow-forms or abcedfg{1}" + "All characters must be a-z, A-Z, 0-9 or !, #, $, %, &, \\, *, +, -, ., ^, _, `, |, ~ " + "For more Information see: {2}"; throw new FormatException(msg.FormatWith(token, Environment.NewLine, "http://www.w3.org/TR/CSP2/#directive-sandbox")); } mTokens.Add(token); IsEmpty = false; }
public void When_validate_null_as_token_it_should_return_false() { Rfc7230Utility.IsToken(null).ShouldBeFalse(); }