yaml-cpp icon indicating copy to clipboard operation
yaml-cpp copied to clipboard

YAML::Node::SetTag broken on inputs starting with "!!"

Open MechatronixX opened this issue 3 months ago • 0 comments

Below is a minimal example to reproduce the issue. It appears using SetTag breaks (w.r.t console/file emitting for the very least) string_node when tagging with anything starting with "!!". Not only that string_node appears broken, but also any node where string_node is inserted. When the tagged node is inserted into root_node, writing the integer to it will not work either. Try SetTag to whatever does not begin with "!!" and the console output looks like you would probably expect, e.g.

some_string: !some_tag hello
some_int: 2

To reproduce:

    YAML::Node root_node{};
    YAML::Node string_node{"hello"};
    string_node.SetTag("!!str"); // Breaks for anything starting with "!!" Comment out this line or tag with e.g. "!some_tag" and it works as expected 

    root_node["some_string"] = string_node;
    root_node["some_int"] = 2;

    std::cout << root_node << std::endl; // Outputs "some_string: !"

Version: commit 2f86d13775d119edbb69af52e5f566fd65c6953b, latest commit on master at the time of posting Os: Ubuntu 24 Compiler: Gcc 14.2.0

MechatronixX avatar Sep 18 '25 17:09 MechatronixX