hjson / hjson-rust

Hjson for Rust
https://hjson.github.io/
MIT License
97 stars 31 forks source link

serde_hjson::from_slice panics on decoding invalid utf8 #19

Open alexanderkjall opened 3 years ago

alexanderkjall commented 3 years ago

Hi

I found that the from_slice function panics if the input isn't a valid utf8 string instead of returning an error value.

Can be reproduced with this unit test:


#[cfg(test)]
mod test {
    use crate::{Map,Value};
    use crate::error::Result;

    #[test]
    pub fn invalid_utf8() {
        let data: Vec<u8> = vec![155];

        let mut sample: Result<Map<String, Value>> = crate::from_slice(&data);
    }
}