@@ -364,8 +364,10 @@ private static async Task<string> DetectBoundaryAsync(RebufferableBinaryReader r
364364 /// </summary>
365365 /// <param name="parameters">The section parameters.</param>
366366 /// <returns>true if the section contains a file, false otherwise.</returns>
367- private bool IsFilePart ( IDictionary < string , string > parameters ! ! )
367+ private bool IsFilePart ( IDictionary < string , string > parameters )
368368 {
369+ if ( parameters == null ) throw new ArgumentNullException ( nameof ( parameters ) ) ;
370+
369371 // A section without any parameter is invalid. It is very likely to contain just a bunch of blank lines.
370372 if ( parameters . Count == 0 ) return false ;
371373
@@ -388,8 +390,10 @@ private bool IsFilePart(IDictionary<string, string> parameters!!)
388390 /// </summary>
389391 /// <param name="parameters">The section parameters.</param>
390392 /// <returns>true if the section contains a data parameter, false otherwise.</returns>
391- private bool IsParameterPart ( IDictionary < string , string > parameters ! ! )
393+ private bool IsParameterPart ( IDictionary < string , string > parameters )
392394 {
395+ if ( parameters == null ) throw new ArgumentNullException ( nameof ( parameters ) ) ;
396+
393397 // A section without any parameter is invalid. It is very likely to contain just a bunch of blank lines.
394398 if ( parameters . Count == 0 ) return false ;
395399
@@ -1052,7 +1056,7 @@ private void ParseSection(RebufferableBinaryReader reader)
10521056 // in the case of single file uploads. Multi-file uploads have Content-Disposition: file according
10531057 // to the spec however in practise it seems that multiple files will be represented by
10541058 // multiple Content-Disposition: form-data files.
1055- var parameters = new Dictionary < string , string > ( ) ;
1059+ var parameters = new Dictionary < string , string > ( StringComparer . OrdinalIgnoreCase ) ;
10561060
10571061 string line = reader . ReadLine ( ) ;
10581062 while ( line != string . Empty )
@@ -1087,8 +1091,9 @@ private void ParseSection(RebufferableBinaryReader reader)
10871091
10881092 // Limit split to 2 splits so we don't accidently split characters in file paths.
10891093 . ToDictionary (
1090- x => x [ 0 ] . Trim ( ) . Replace ( "\" " , string . Empty ) . ToLower ( ) ,
1091- x => x [ 1 ] . Trim ( ) . Replace ( "\" " , string . Empty ) ) ;
1094+ x => x [ 0 ] . Trim ( ) . Replace ( "\" " , string . Empty ) ,
1095+ x => x [ 1 ] . Trim ( ) . Replace ( "\" " , string . Empty ) ,
1096+ StringComparer . OrdinalIgnoreCase ) ;
10921097
10931098 // Here we just want to push all the values that we just retrieved into the
10941099 // parameters dictionary.
@@ -1151,7 +1156,7 @@ private async Task ParseSectionAsync(RebufferableBinaryReader reader, Cancellati
11511156 // in the case of single file uploads. Multi-file uploads have Content-Disposition: file according
11521157 // to the spec however in practise it seems that multiple files will be represented by
11531158 // multiple Content-Disposition: form-data files.
1154- var parameters = new Dictionary < string , string > ( ) ;
1159+ var parameters = new Dictionary < string , string > ( StringComparer . OrdinalIgnoreCase ) ;
11551160
11561161 string line = await reader . ReadLineAsync ( cancellationToken ) . ConfigureAwait ( false ) ;
11571162 while ( line != string . Empty )
@@ -1186,8 +1191,9 @@ private async Task ParseSectionAsync(RebufferableBinaryReader reader, Cancellati
11861191
11871192 // Limit split to 2 splits so we don't accidently split characters in file paths.
11881193 . ToDictionary (
1189- x => x [ 0 ] . Trim ( ) . Replace ( "\" " , string . Empty ) . ToLower ( ) ,
1190- x => x [ 1 ] . Trim ( ) . Replace ( "\" " , string . Empty ) ) ;
1194+ x => x [ 0 ] . Trim ( ) . Replace ( "\" " , string . Empty ) ,
1195+ x => x [ 1 ] . Trim ( ) . Replace ( "\" " , string . Empty ) ,
1196+ StringComparer . OrdinalIgnoreCase ) ;
11911197
11921198 // Here we just want to push all the values that we just retrieved into the
11931199 // parameters dictionary.
@@ -1269,8 +1275,11 @@ private IDictionary<string, string> GetAdditionalParameters(IDictionary<string,
12691275 {
12701276 var wellKnownParameters = new [ ] { "name" , "filename" , "content-type" , "content-disposition" } ;
12711277 var additionalParameters = parameters
1272- . Where ( param => ! wellKnownParameters . Contains ( param . Key ) )
1273- . ToDictionary ( x => x . Key , x => x . Value ) ;
1278+ . Where ( param => ! wellKnownParameters . Contains ( param . Key , StringComparer . OrdinalIgnoreCase ) )
1279+ . ToDictionary (
1280+ x => x . Key ,
1281+ x => x . Value ,
1282+ StringComparer . OrdinalIgnoreCase ) ;
12741283 return additionalParameters ;
12751284 }
12761285
0 commit comments