Handle "!!" tag overriding.

This commit is contained in:
Ethiraric 2023-11-19 16:36:04 +01:00
parent ffed282a9f
commit 06a6fb34c1
2 changed files with 13 additions and 11 deletions

View file

@ -948,14 +948,20 @@ impl<T: Iterator<Item = char>> Parser<T> {
/// Resolve a tag from the handle and the suffix.
fn resolve_tag(&self, mark: Marker, handle: &str, suffix: String) -> Result<Tag, ScanError> {
if handle == "!!" {
// "!!" is a shorthand for "tag:yaml.org,2002:".
Ok(Tag {
// "!!" is a shorthand for "tag:yaml.org,2002:". However, that default can be
// overridden.
match self.tags.get("!!") {
Some(prefix) => Ok(Tag {
handle: prefix.to_string(),
suffix,
}),
None => Ok(Tag {
handle: "tag:yaml.org,2002:".to_string(),
suffix,
})
}),
}
} else if handle.is_empty() && suffix == "!" {
// "!" is a shorthand for "whatever would be the default". However, that
// default can be overridden.
// "!" introduces a local tag. Local tags may have their prefix overridden.
match self.tags.get("") {
Some(prefix) => Ok(Tag {
handle: prefix.to_string(),

View file

@ -297,10 +297,6 @@ fn expected_events(expected_tree: &str) -> Vec<String> {
#[rustfmt::skip]
static EXPECTED_FAILURES: &[&str] = &[
// These seem to be API limited (not enough information on the event stream level)
// Cannot resolve tag namespaces
"P76L", // overriding the `!!` namespace!
// These seem to be plain bugs
// Leading TAB in literal scalars
"96NN-00",