Skip to content

emit secondary tag handles (e.g. !!str) on Node::SetTag#1437

Open
c-tonneslan wants to merge 1 commit into
jbeder:masterfrom
c-tonneslan:fix-emit-set-tag-double-bang
Open

emit secondary tag handles (e.g. !!str) on Node::SetTag#1437
c-tonneslan wants to merge 1 commit into
jbeder:masterfrom
c-tonneslan:fix-emit-set-tag-double-bang

Conversation

@c-tonneslan
Copy link
Copy Markdown

Closes #1373.

When a node's tag started with !! (the YAML secondary tag handle, e.g. !!str), EmitFromEvents::EmitProps stripped a single ! and emitted the rest as a LocalTag. The remaining !str then failed the local-tag character regex on its inner ! and the emitter bailed out with INVALID_TAG, truncating the output:

YAML::Node root;
YAML::Node s{"hello"};
s.SetTag("!!str");
root["some_string"] = s;
root["some_int"] = 2;
std::cout << root;  // -> "some_string: !"

Route the !! case through SecondaryTag with the rest of the tag content. After this:

some_string: !!str hello
some_int: 2

Two regression tests added under NodeTest covering both the secondary (!!) and primary (!) handle paths.

When a node's tag started with "!!" — the YAML secondary tag handle,
as in "!!str" or "!!int" — EmitFromEvents stripped a single '!' and
emitted the rest as a LocalTag. The remaining string ("!str") then
failed the LocalTag character regex on the inner '!' and the emitter
bailed out with INVALID_TAG, truncating output after "!".

Reproduction from jbeder#1373:

    YAML::Node root;
    YAML::Node s{"hello"};
    s.SetTag("!!str");
    root["some_string"] = s;
    root["some_int"] = 2;
    std::cout << root;  // -> "some_string: !"

Recognize the "!!" prefix in EmitProps and route it through
SecondaryTag with the rest of the tag content. After this:

    some_string: !!str hello
    some_int: 2

Added two regression tests under NodeTest covering both the secondary
("!!") and primary ("!") handle paths.

Closes jbeder#1373.

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant