@@ -313,13 +313,8 @@ internal static class Rfc8941Parser
313313 {
314314 CheckIndex ( index ) ;
315315 var spanLength = source . Length ;
316- if ( spanLength - index < 1 )
317- {
318- result = default ;
319- return new ( index , "insufficient characters for inner list" ) ;
320- }
321-
322- if ( source [ index ] != '(' )
316+ if ( spanLength - index < 1
317+ || source [ index ] != '(' )
323318 {
324319 result = default ;
325320 return new ( index , "missing opening parentheses" ) ;
@@ -769,16 +764,11 @@ internal static class Rfc8941Parser
769764 {
770765 CheckIndex ( index ) ;
771766 var spanLength = source . Length ;
772- if ( spanLength - index < 1 )
767+ if ( spanLength - index < 1
768+ || source [ index ] != '"' )
773769 {
774770 result = "" ;
775- return new ( index , "insufficient characters for string" ) ;
776- }
777-
778- if ( source [ index ] != '"' )
779- {
780- result = "" ;
781- return new ( index , "missing opening double quote" ) ;
771+ return new ( index , "missing opening double quote for string" ) ;
782772 }
783773
784774 ++ index ;
@@ -896,33 +886,28 @@ internal static class Rfc8941Parser
896886 {
897887 CheckIndex ( index ) ;
898888 var spanLength = source . Length ;
899- if ( spanLength - index < 1 )
889+ if ( spanLength - index < 1
890+ || source [ index ] != '%' )
900891 {
901892 result = DisplayString . Empty ;
902- return new ( index , "insufficient characters for display string" ) ;
903- }
904-
905- var character = source [ index ] ;
906- if ( character != '%' )
907- {
908- result = DisplayString . Empty ;
909- return new ( index , "invalid leading display string character" ) ;
893+ return new ( index , "missing leading display string character" ) ;
910894 }
911895
912896 ++ index ;
913897
914- if ( source [ index ] != '"' )
898+ if ( spanLength - index < 1
899+ || source [ index ] != '"' )
915900 {
916901 result = DisplayString . Empty ;
917- return new ( index , "missing opening double quote" ) ;
902+ return new ( index , "missing opening double quote for display string " ) ;
918903 }
919904
920905 ++ index ;
921906
922907 if ( spanLength - index < 1 )
923908 {
924909 result = DisplayString . Empty ;
925- return new ( index , "insufficient characters for display string value" ) ;
910+ return new ( index , "missing display string value" ) ;
926911 }
927912
928913 var initialIndex = index ;
@@ -933,7 +918,7 @@ internal static class Rfc8941Parser
933918 {
934919 while ( localIndex != spanLength )
935920 {
936- character = source [ localIndex ] ;
921+ var character = source [ localIndex ] ;
937922 switch ( character )
938923 {
939924 case '"' :
@@ -1092,24 +1077,19 @@ internal static class Rfc8941Parser
10921077 {
10931078 CheckIndex ( index ) ;
10941079 var spanLength = source . Length ;
1095- if ( spanLength - index < 2 )
1096- {
1097- result = Array . Empty < byte > ( ) ;
1098- return new ( index , "insufficient characters for byte sequence" ) ;
1099- }
1100-
1101- if ( source [ index ] != ':' )
1080+ if ( spanLength - index < 1
1081+ || source [ index ] != ':' )
11021082 {
11031083 result = Array . Empty < byte > ( ) ;
1104- return new ( index , "invalid opening byte sequence character" ) ;
1084+ return new ( index , "missing opening byte sequence character" ) ;
11051085 }
11061086
11071087 var initialIndex = ++ index ;
11081088 var slice = source . Slice ( initialIndex ) ;
11091089 var length = slice . IndexOf ( ':' ) ;
11101090 if ( length < 0 )
11111091 {
1112- index + = spanLength - 1 ;
1092+ index = spanLength ;
11131093 result = Array . Empty < byte > ( ) ;
11141094 return new ( index , "missing closing byte sequence character" ) ;
11151095 }
0 commit comments