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

Bug: U+2028 not escaped in strings #21

Open
ghost opened this issue May 6, 2020 · 1 comment
Open

Bug: U+2028 not escaped in strings #21

ghost opened this issue May 6, 2020 · 1 comment

Comments

@ghost
Copy link

ghost commented May 6, 2020

Description

  • Contrary to recommendations of the spec, the Unicode code points U+2028 and U+2029 are not escaped upon serialization. See Section 5.2 of the specification.
  • Deserialization fails when an input string contains Unicode code points U+2028 or U+2029.

Tested Versions

json5 = "0.2.7"
serde = { version = "1.0.106", features = ["derive"] }

Testcase

#[cfg(test)]
mod tests {
    use serde::{Serialize, Deserialize};
    use json5;

    #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
    struct S {
        value: String
    }

    #[test]
    fn roundtrip_u2028() {
        let original = S {
            value: "\u{2028}".to_string()
        };

        let serialized = json5::to_string(&original).unwrap();
        let deserialized = json5::from_str::<S>(&serialized).unwrap();

        assert_eq!(deserialized, original);
    }
}
@penso
Copy link

penso commented Jul 24, 2022

Any update on this one still failing? I just got bitten with parsing a remote JSON file which includes "\u{2028}". I've fixed it by replacing it before passing it to json5.

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

1 participant