Skip to content

Escape inner > when emitting verbatim tag suffixes#58

Merged
jskoiz merged 2 commits into
mainfrom
fix/emit-escape-tag-suffix-gt
Jun 5, 2026
Merged

Escape inner > when emitting verbatim tag suffixes#58
jskoiz merged 2 commits into
mainfrom
fix/emit-escape-tag-suffix-gt

Conversation

@jskoiz

@jskoiz jskoiz commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Summary

A verbatim tag suffix (!<...>) containing an inner > followed by a tag terminator was emitted with the > left literal, which closed the verbatim tag early and produced YAML that failed to reparse. For example, parse_str("!<%3E:G> value") parses a node with tag suffix >:G, but re-emitting it produced !<>:G> value, which the parser then rejected with "tag must be separated from the node value by whitespace."

Fix

  • push_uri_escaped_tag_suffix now percent-escapes > to %3E in the verbatim form. The parser already un-escapes %3E back to > (decode_tag_uri_escapes), so emit and parse stay inverse. Handle-form escaping (colons) is unchanged, and no other currently-literal characters are over-escaped.
  • The tag property-test generator (arb_tag) is widened to generate suffixes containing indicator characters (including >, :, space, and flow indicators); this had been narrowed in a way that hid the bug. The round-trip property now exercises these suffixes and passes because of the emitter fix.
  • Added focused regression tests for awkward suffixes (>:G, a>:b, >>:c, a>:b c) and for the parse-reachable !<%3E:G> repro.

Testing

  • cargo build --all-features, cargo clippy --all-features (clean)
  • cargo test --all-features (all suites pass)
  • parser_properties round-trip property run repeatedly with PROPTEST_CASES=4000 to exercise the widened, randomized generator

jskoiz added 2 commits June 5, 2026 09:15
A verbatim tag suffix (`!<...>`) containing an inner `>` followed by a
tag terminator emitted YAML that closed the tag early and failed to
reparse. Percent-escape `>` to `%3E` in the verbatim form so the
emitted tag matches what the parser un-escapes on read.

Widen the tag property-test generator to produce suffixes containing
indicator characters, and add regression coverage for awkward suffixes.
@jskoiz jskoiz merged commit d374667 into main Jun 5, 2026
7 checks passed
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.

1 participant