File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed
Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -918,18 +918,37 @@ class Scanner {
918918 ///
919919 /// %TAG !yaml! tag:yaml.org,2002: \n
920920 /// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
921+ ///
922+ /// OR
923+ ///
924+ /// %TAG !yaml! !dart \n
925+ /// ^^^^^^^^^^^^^^^^^
926+ ///
921927 Token _scanTagDirectiveValue (LineScannerState start) {
922928 _skipBlanks ();
923929
924- var handle = _scanTagHandle (directive: true );
930+ final handle = _scanTagHandle (directive: true );
925931 if (! _isBlank) {
926932 throw YamlException ('Expected whitespace.' , _scanner.emptySpan);
927933 }
928934
929935 _skipBlanks ();
930936
931- var prefix = _scanTagUri ();
932- if (! _isBlankOrEnd) {
937+ /// Both tag uri and local tags can be used as prefixes.
938+ ///
939+ /// See: https://yaml.org/spec/1.2.2/#6822-tag-prefixes
940+ var prefix = _scanner.peekChar () == EXCLAMATION
941+ ? _scanTagHandle (directive: true , isPrefix: true )
942+ : '' ;
943+
944+ prefix += _scanTagUri (); // Readability's sake
945+
946+ if (prefix.isEmpty) {
947+ throw YamlException (
948+ 'Expected a non-empty global tag prefix' ,
949+ _scanner.emptySpan,
950+ );
951+ } else if (! _isBlankOrEnd) {
933952 throw YamlException ('Expected whitespace.' , _scanner.emptySpan);
934953 }
935954
You can’t perform that action at this time.
0 commit comments