Skip to content

Fix serialization of strings starting with YAML indicator characters#508

Open
rioki wants to merge 8 commits intofktn-k:developfrom
rioki:bug/string_output
Open

Fix serialization of strings starting with YAML indicator characters#508
rioki wants to merge 8 commits intofktn-k:developfrom
rioki:bug/string_output

Conversation

@rioki
Copy link

@rioki rioki commented Nov 17, 2025

This PR corrects a round-trip issue where certain string values were emitted as plain scalars even though YAML interprets them as structural tokens. For example, a value like "***" was serialized as:

pass: ***

which YAML parses as an alias, causing deserialization to fail.

The serializer now performs a conservative scan of escaped string contents and quotes strings that begin with, or contain, YAML indicator characters that could change parsing semantics (e.g. *, &, !, #, [/], {/}, etc.). This preserves the intended string type without modifying the parser or scalar_scanner.

All existing tests pass, and the added round-trip test covering this case succeeds.


Pull Request Checklist

Read the CONTRIBUTING.md file for detailed information.

  • Changes are described in the pull request or in a referenced issue.
  • The test suite compiles and runs without any error.
  • The code coverage on your branch is 100%.
  • The documentation is updated if you added/changed a feature.

Please don't

  • The C++11 support varies between different compilers and versions. Please note the list of supported compilers. Some compilers like GCC 4.7 (and earlier), Clang 3.3 (and earlier), or Microsoft Visual Studio 13.0 and earlier are known not to work due to missing or incomplete C++11 support. Please refrain from proposing changes that work around these compiler's limitations with #ifdefs or other means.
  • Please refrain from proposing changes that would break YAML specifications. If you propose a conformant extension of YAML to be supported by the library, please motivate this extension.
  • Please do not open pull requests that address multiple issues.

@rioki rioki requested a review from fktn-k as a code owner November 17, 2025 21:32
@rioki
Copy link
Author

rioki commented Nov 17, 2025

Not sure why the CI tripped... it failed on git checkout... If I can do anything to help on my end.

Rolled out test and double checked coverage. Removed bogus empty string test. Rerun amalgamation.
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