private static void CheckInvalidNewLine(string value)
 {
     if (value != null && HttpRuleParser.ContainsInvalidNewLine(value))
     {
         throw new FormatException(SR.net_http_headers_no_newlines);
     }
 }
예제 #2
0
 private static bool ContainsInvalidNewLine(string value, string name)
 {
     if (HttpRuleParser.ContainsInvalidNewLine(value))
     {
         return(true);
     }
     return(false);
 }
예제 #3
0
        private static void CheckInvalidNewLine(string value)
        {
            if (value == null)
            {
                return;
            }

            if (HttpRuleParser.ContainsInvalidNewLine(value))
            {
                throw new FormatException("New-line characters in header values must be followed by a white-space character.");
            }
        }
 private static bool ContainsInvalidNewLine(string value, string name)
 {
     if (!HttpRuleParser.ContainsInvalidNewLine(value))
     {
         return(false);
     }
     if (NetEventSource.IsEnabled)
     {
         NetEventSource.Error((object)null, (object)SR.Format(SR.net_http_log_headers_no_newlines, (object)name, (object)value), nameof(ContainsInvalidNewLine));
     }
     return(true);
 }
예제 #5
0
        /// <summary>
        /// Allows for arbitrary header values without validation (aside from newline, which is always invalid in a header value).
        /// </summary>
        private static int ParseWithoutValidation(string value, int startIndex, out object?parsedValue)
        {
            if (HttpRuleParser.ContainsInvalidNewLine(value, startIndex))
            {
                parsedValue = null;
                return(0);
            }

            string result = value.Substring(startIndex);

            parsedValue = result;
            return(result.Length);
        }
예제 #6
0
        private static int ParseMailAddress(string value, int startIndex, out object parsedValue)
        {
            parsedValue = null;

            if (HttpRuleParser.ContainsInvalidNewLine(value, startIndex))
            {
                return(0);
            }

            string result = value.Substring(startIndex);

            if (!HeaderUtilities.IsValidEmailAddress(result))
            {
                return(0);
            }

            parsedValue = result;
            return(result.Length);
        }