Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not quote plain scalars with '-' symbol #354

Closed
dbarkar opened this issue Feb 19, 2023 · 0 comments · Fixed by #414
Closed

Do not quote plain scalars with '-' symbol #354

dbarkar opened this issue Feb 19, 2023 · 0 comments · Fixed by #414

Comments

@dbarkar
Copy link

dbarkar commented Feb 19, 2023

Please reconsider current rules for quoting scalars:

const bool needs_quotes = (
    was_quoted
    ||
    (
        ( ! s.is_number())
        &&
        (
            // has leading whitespace
            s.begins_with_any(" \n\t\r")
            ||
            // looks like reference or anchor or would be treated as a directive
            s.begins_with_any("*&%")
            ||
            s.begins_with("<<")
            ||
            // has trailing whitespace
            s.ends_with_any(" \n\t\r")
            ||
            // has special chars
            (s.first_of("#:-?,\n{}[]'\"") != npos)
        )
    )
);

List of escaped characters: https://yaml.org/spec/1.2.2/#57-escaped-characters
Plain scalar type: https://yaml.org/spec/1.2.2/#733-plain-style
At least, strings with '-' should not be quoted, there are even examples with such strings in standard.

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 a pull request may close this issue.

2 participants