dtolnay / serde-yaml

Strongly typed YAML library for Rust
Apache License 2.0
960 stars 157 forks source link

from_str::<Value>() interprets entire input as string in some cases #372

Closed cloneable closed 1 year ago

cloneable commented 1 year ago

from_str::<Value>() interprets entire input as string.

fn main() {
    let toml_actually = r#"
presectionfield = 123

[never.valid.yaml]
field = true
otherfield = "string"
"#;
    serde_yaml::from_str::<serde_yaml::Value>(&toml_actually).unwrap_err();
}

Removing the "presectionfield" makes serde_yaml return an error.

dtolnay commented 1 year ago

This is consistent with the spec as far as I can tell. That input is indeed a valid yaml document containing a single unquoted string.