@@ -221,7 +221,7 @@ internal bool TryGetValues(HeaderDescriptor descriptor, [NotNullWhen(true)] out
221221 internal bool Contains ( HeaderDescriptor descriptor )
222222 {
223223 // We can't just call headerStore.ContainsKey() since after parsing the value the header may not exist
224- // anymore (if the value contains invalid newline chars, we remove the header). So try to parse the
224+ // anymore (if the value contains newline chars, we remove the header). So try to parse the
225225 // header value.
226226 return _headerStore != null && TryGetAndParseHeaderInfo ( descriptor , out _ ) ;
227227 }
@@ -318,7 +318,7 @@ private IEnumerator<KeyValuePair<string, IEnumerable<string>>> GetEnumeratorCore
318318 // values.
319319 if ( ! ParseRawHeaderValues ( descriptor , info , removeEmptyHeader : false ) )
320320 {
321- // We have an invalid header value (contains invalid newline chars). Delete it.
321+ // We have an invalid header value (contains newline chars). Delete it.
322322 _headerStore . Remove ( descriptor ) ;
323323 }
324324 else
@@ -726,18 +726,17 @@ private bool ParseRawHeaderValues(HeaderDescriptor descriptor, HeaderStoreItemIn
726726 }
727727
728728 // At this point all values are either in info.ParsedValue, info.InvalidValue, or were removed since they
729- // contain invalid newline chars. Reset RawValue.
729+ // contain newline chars. Reset RawValue.
730730 info . RawValue = null ;
731731
732- // During parsing, we removed the value since it contains invalid newline chars. Return false to indicate that
732+ // During parsing, we removed the value since it contains newline chars. Return false to indicate that
733733 // this is an empty header. If the caller specified to remove empty headers, we'll remove the header before
734734 // returning.
735735 if ( ( info . InvalidValue == null ) && ( info . ParsedValue == null ) )
736736 {
737737 if ( removeEmptyHeader )
738738 {
739- // After parsing the raw value, no value is left because all values contain invalid newline
740- // chars.
739+ // After parsing the raw value, no value is left because all values contain newline chars.
741740 Debug . Assert ( _headerStore != null ) ;
742741 _headerStore . Remove ( descriptor ) ;
743742 }
@@ -754,7 +753,7 @@ private static void ParseMultipleRawHeaderValues(HeaderDescriptor descriptor, He
754753 {
755754 foreach ( string rawValue in rawValues )
756755 {
757- if ( ! ContainsInvalidNewLine ( rawValue , descriptor . Name ) )
756+ if ( ! ContainsNewLine ( rawValue , descriptor . Name ) )
758757 {
759758 AddParsedValue ( info , rawValue ) ;
760759 }
@@ -779,7 +778,7 @@ private static void ParseSingleRawHeaderValue(HeaderDescriptor descriptor, Heade
779778
780779 if ( descriptor . Parser == null )
781780 {
782- if ( ! ContainsInvalidNewLine ( rawValue , descriptor . Name ) )
781+ if ( ! ContainsNewLine ( rawValue , descriptor . Name ) )
783782 {
784783 AddParsedValue ( info , rawValue ) ;
785784 }
@@ -868,7 +867,7 @@ private static bool TryParseAndAddRawHeaderValue(HeaderDescriptor descriptor, He
868867 }
869868 else
870869 {
871- if ( ! ContainsInvalidNewLine ( value , descriptor . Name ) && addWhenInvalid )
870+ if ( ! ContainsNewLine ( value , descriptor . Name ) && addWhenInvalid )
872871 {
873872 AddInvalidValue ( info , value ) ;
874873 }
@@ -885,7 +884,7 @@ private static bool TryParseAndAddRawHeaderValue(HeaderDescriptor descriptor, He
885884 }
886885
887886 Debug . Assert ( value != null ) ;
888- if ( ! ContainsInvalidNewLine ( value , descriptor . Name ) && addWhenInvalid )
887+ if ( ! ContainsNewLine ( value , descriptor . Name ) && addWhenInvalid )
889888 {
890889 AddInvalidValue ( info , value ?? string . Empty ) ;
891890 }
@@ -973,8 +972,8 @@ private void ParseAndAddValue(HeaderDescriptor descriptor, HeaderStoreItemInfo i
973972 if ( descriptor . Parser == null )
974973 {
975974 // If we don't have a parser for the header, we consider the value valid if it doesn't contains
976- // invalid newline characters. We add the values as "parsed value". Note that we allow empty values.
977- CheckInvalidNewLine ( value ) ;
975+ // newline characters. We add the values as "parsed value". Note that we allow empty values.
976+ CheckContainsNewLine ( value ) ;
978977 AddParsedValue ( info , value ?? string . Empty ) ;
979978 return ;
980979 }
@@ -1077,22 +1076,22 @@ private bool TryGetHeaderDescriptor(string name, out HeaderDescriptor descriptor
10771076 return false ;
10781077 }
10791078
1080- private static void CheckInvalidNewLine ( string ? value )
1079+ private static void CheckContainsNewLine ( string ? value )
10811080 {
10821081 if ( value == null )
10831082 {
10841083 return ;
10851084 }
10861085
1087- if ( HttpRuleParser . ContainsInvalidNewLine ( value ) )
1086+ if ( HttpRuleParser . ContainsNewLine ( value ) )
10881087 {
10891088 throw new FormatException ( SR . net_http_headers_no_newlines ) ;
10901089 }
10911090 }
10921091
1093- private static bool ContainsInvalidNewLine ( string value , string name )
1092+ private static bool ContainsNewLine ( string value , string name )
10941093 {
1095- if ( HttpRuleParser . ContainsInvalidNewLine ( value ) )
1094+ if ( HttpRuleParser . ContainsNewLine ( value ) )
10961095 {
10971096 if ( NetEventSource . Log . IsEnabled ( ) ) NetEventSource . Error ( null , SR . Format ( SR . net_http_log_headers_no_newlines , name , value ) ) ;
10981097 return true ;
0 commit comments