File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -414,6 +414,35 @@ public void Issue_553_562()
414414 }
415415 }
416416
417+ [ Fact ]
418+ public void Plain_Scalar_outside_of_flow_allows_braces ( )
419+ {
420+ AssertSequenceOfTokensFrom ( Yaml . ScannerForText ( @"value: -[123]" ) ,
421+ StreamStart ,
422+ BlockMappingStart ,
423+ Key ,
424+ PlainScalar ( "value" ) ,
425+ Value ,
426+ PlainScalar ( "-[123]" ) ,
427+ BlockEnd ,
428+ StreamEnd ) ;
429+ }
430+
431+ [ Fact ]
432+ public void Plain_Scalar_inside_flow_does_not_allow_braces ( )
433+ {
434+ AssertPartialSequenceOfTokensFrom ( Yaml . ScannerForText ( @"
435+ [
436+ value: -[123]
437+ ]" ) ,
438+ StreamStart ,
439+ FlowSequenceStart ,
440+ Key ,
441+ PlainScalar ( "value" ) ,
442+ Value ,
443+ Error ( "Invalid key indicator format." ) ) ;
444+ }
445+
417446 private void AssertPartialSequenceOfTokensFrom ( Scanner scanner , params Token [ ] tokens )
418447 {
419448 var tokenNumber = 1 ;
Original file line number Diff line number Diff line change @@ -151,6 +151,11 @@ protected static AnchorAlias AnchorAlias(string alias)
151151 return new AnchorAlias ( new AnchorName ( alias ) ) ;
152152 }
153153
154+ protected static Error Error ( string value )
155+ {
156+ return new Error ( value , new Mark ( ) , new Mark ( ) ) ;
157+ }
158+
154159 protected static Comment StandaloneComment ( string text )
155160 {
156161 return new Comment ( text , false ) ;
Original file line number Diff line number Diff line change @@ -398,7 +398,7 @@ private void FetchNextToken()
398398 FetchBlockEntry ( ) ;
399399 return ;
400400 }
401- else if ( analyzer . Check ( ",[]{}" , 1 ) )
401+ else if ( flowLevel > 0 && analyzer . Check ( ",[]{}" , 1 ) )
402402 {
403403 tokens . Enqueue ( new Error ( "Invalid key indicator format." , cursor . Mark ( ) , cursor . Mark ( ) ) ) ;
404404 }
Original file line number Diff line number Diff line change 2222namespace YamlDotNet . Core . Tokens
2323{
2424 /// <summary>
25- /// Base class for YAML tokens.
25+ /// Error tokens.
2626 /// </summary>
27- internal class Error : Token
27+ public class Error : Token
2828 {
2929 /// <summary>
30- /// Gets the value of the comment
30+ /// Gets the value of the error
3131 /// </summary>
32- internal string Value { get ; }
32+ public string Value { get ; }
3333
34- internal Error ( string value , Mark start , Mark end )
34+ public Error ( string value , Mark start , Mark end )
3535 : base ( start , end )
3636 {
3737 Value = value ;
You can’t perform that action at this time.
0 commit comments