File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,8 @@ class RuntimeParser {
75
75
76
76
// We don't care about comments or sections at runtime
77
77
if ( ch === '/' ||
78
- ( ch === '#' && [ ' ' , '#' ] . includes ( this . _source [ this . _index + 1 ] ) ) ) {
78
+ ( ch === '#' &&
79
+ [ ' ' , '#' , '\n' ] . includes ( this . _source [ this . _index + 1 ] ) ) ) {
79
80
this . skipComment ( ) ;
80
81
return ;
81
82
}
@@ -340,7 +341,9 @@ class RuntimeParser {
340
341
this . skipBlankLines ( ) ;
341
342
342
343
if ( this . _source [ this . _index ] !== ' ' ) {
343
- // No indentation means we're done with this message.
344
+ // No indentation means we're done with this message. Callers should check
345
+ // if the return value here is null. It may be OK for messages, but not OK
346
+ // for terms, attributes and variants.
344
347
return firstLineContent ;
345
348
}
346
349
@@ -759,6 +762,10 @@ class RuntimeParser {
759
762
760
763
const val = this . getPattern ( ) ;
761
764
765
+ if ( val === null ) {
766
+ throw this . error ( 'Expected attribute to have a value' ) ;
767
+ }
768
+
762
769
if ( typeof val === 'string' ) {
763
770
attrs [ key ] = val ;
764
771
} else {
@@ -806,11 +813,13 @@ class RuntimeParser {
806
813
807
814
this . skipInlineWS ( ) ;
808
815
809
- const variant = {
810
- key,
811
- val : this . getPattern ( )
812
- } ;
813
- variants [ index ++ ] = variant ;
816
+ const val = this . getPattern ( ) ;
817
+
818
+ if ( val === null ) {
819
+ throw this . error ( 'Expected variant to have a value' ) ;
820
+ }
821
+
822
+ variants [ index ++ ] = { key, val} ;
814
823
815
824
this . skipWS ( ) ;
816
825
}
You can’t perform that action at this time.
0 commit comments