File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed
Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -1068,16 +1068,14 @@ class Scanner {
10681068 } else {
10691069 tagUri = _scanTagUri (); // !<foo:uri>
10701070
1071- // Expect !<foo:uri> to be !<tag:yaml.org,2002:*>
1072- switch (tagUri.replaceFirst ('tag:yaml.org,2002:' , '' )) {
1073- case 'map' || 'seq' || 'str' || 'null' || 'bool' || 'int' || 'float' :
1074- break ;
1075-
1076- default :
1077- throw YamlException (
1078- 'Invalid tag uri used as a verbatim tag' ,
1079- _scanner.spanFrom (start),
1080- );
1071+ /// Expect !<foo:uri> to be !<tag:*> (a global tag)
1072+ ///
1073+ /// See: https://yaml.org/spec/1.2.2/#3212-tags
1074+ if (! tagUri.startsWith ('tag:' ) || tagUri.substring (4 ).isEmpty) {
1075+ throw YamlException (
1076+ 'Invalid tag uri used as a verbatim tag' ,
1077+ _scanner.spanFrom (start),
1078+ );
10811079 }
10821080 }
10831081
Original file line number Diff line number Diff line change @@ -1140,6 +1140,8 @@ void main() {
11401140 test ('[Example 6.25]' , () {
11411141 expectYamlFails ('- !<!> foo' );
11421142 expectYamlFails ('- !<\$ :?> foo' );
1143+ expectYamlFails ('- !<tag:>' ); // Incomplete verbatim tag uri
1144+ expectYamlFails ('- !<improvised:tag>' );
11431145 });
11441146
11451147 test ('[Example 6.26]' , () {
You can’t perform that action at this time.
0 commit comments