File tree Expand file tree Collapse file tree 1 file changed +21
-7
lines changed
Expand file tree Collapse file tree 1 file changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -359,24 +359,38 @@ class Content
359359
360360 public static bool TryParse ( string s , out Content content )
361361 {
362- var index = s . IndexOf ( '=' ) ;
362+ var equalsIndex = s . IndexOf ( '=' ) ;
363+ var colonIndex = s . IndexOf ( ':' ) ;
364+ if ( equalsIndex == - 1 && colonIndex == - 1 )
365+ {
366+ content = default ;
367+ return false ;
368+ }
369+
363370 var contentType = default ( ContentLocation ) ;
364- if ( index == - 1 )
371+ var index = default ( int ) ;
372+ if ( equalsIndex > - 1 && colonIndex > - 1 )
365373 {
366- index = s . IndexOf ( ':' ) ;
367- if ( index == - 1 )
374+ if ( equalsIndex < colonIndex )
368375 {
369- content = default ;
370- return false ;
376+ contentType = ContentLocation . Body ;
377+ index = equalsIndex ;
371378 }
372379 else
373380 {
374381 contentType = ContentLocation . Header ;
382+ index = colonIndex ;
375383 }
376384 }
377- else
385+ else if ( equalsIndex > - 1 )
378386 {
379387 contentType = ContentLocation . Body ;
388+ index = equalsIndex ;
389+ }
390+ else
391+ {
392+ contentType = ContentLocation . Header ;
393+ index = colonIndex ;
380394 }
381395
382396 var property = s . Substring ( 0 , index ) ;
You can’t perform that action at this time.
0 commit comments