Skip to content

Commit 7e4f598

Browse files
committed
Never resolve verbatim tags
1 parent ff34308 commit 7e4f598

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

pkgs/yaml/lib/src/parser.dart

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,23 @@ class Parser {
290290
}
291291

292292
String? tag;
293-
if (tagToken != null) {
294-
if (tagToken!.handle == null) {
295-
tag = tagToken!.suffix;
293+
if (tagToken
294+
case TagToken(:final handle, :final suffix, :final isVerbatim)) {
295+
/// Verbatim tags cannot be resolved as global tags.
296+
///
297+
/// See: https://yaml.org/spec/1.2.2/#691-node-tags
298+
/// - Verbatim tags section
299+
/// - All 1.2.* versions behave this way
300+
if (handle == null || isVerbatim) {
301+
tag = suffix;
296302
} else {
297-
var tagDirective = _tagDirectives[tagToken!.handle];
303+
final tagDirective = _tagDirectives[handle];
304+
298305
if (tagDirective == null) {
299306
throw YamlException('Undefined tag handle.', tagToken!.span);
300307
}
301308

302-
tag = tagDirective.prefix + (tagToken?.suffix ?? '');
309+
tag = tagDirective.prefix + suffix;
303310
}
304311
}
305312

0 commit comments

Comments
 (0)