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

Unexpected "control characters are not allowed" #872

Open
LuisBecker0 opened this issue Jul 15, 2022 · 3 comments
Open

Unexpected "control characters are not allowed" #872

LuisBecker0 opened this issue Jul 15, 2022 · 3 comments

Comments

@LuisBecker0
Copy link

LuisBecker0 commented Jul 15, 2022

According to chapter 5 of the yaml specification I would expect the library to parse streams with non-C0 control characters inside quoted scalars. I encountered an Issue when parsing a stream containing the C1 control character "\x80". See playground.

@fenollp
Copy link

fenollp commented Sep 16, 2022

See #737

@WGH-
Copy link

WGH- commented Sep 30, 2022

Looks like this library still implements YAML 1.1, which is not JSON superset. PyYAML/LibYAML also have exactly the same problem.

@gitsang
Copy link

gitsang commented Jan 17, 2024

If control characters cannot be parsed correctly, can an option be provided for users to replace control characters with \uFFFD or other characters? This is to ensure that other content can be parsed correctly.

I have tried using replacement before deserialization, but I cannot guarantee that it will cover all unsupported cases by libraries.

func Replace(in string, replacer func(rune) bool, replacement rune) string {
        var result bytes.Buffer
        for _, r := range in {
                if replacer(r) {
                        result.WriteRune(replacement)
                } else {
                        result.WriteRune(r)
                }
        }
        return result.String()
}

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

No branches or pull requests

4 participants