samscott89 / serde_qs

Serde support for querystring-style strings
Apache License 2.0
193 stars 67 forks source link

Bug in non strict mode #70

Open wbcat opened 1 year ago

wbcat commented 1 year ago

I get panics in some of the examples. Maybe this is because of max_depth being 0?

// Rust 1.64, serde_qs 0.10.1, Debian 11, x86_64
#![allow(unused)]
#[derive(Debug, Default, serde::Serialize, serde::Deserialize)]
#[serde(default)]
struct Form {
    id: i64,
    name: String,
    vec: Vec<String>,
}

fn main() {
    //  works correct
    let s = "id=2";
    let s = "name=test";
    let s = "id=3&name=&vec%5B1%5D=Vector";

    // runs, but does not fill the struct correct
    let s = "vec[0]=Vector";
    let s = "vec%5B1%5D=Vector";

    // panics
    let s = "name=&vec%5B1%5D=Vector";
    let s = "name=&vec[0]c=Vector";
    let s = "name=test&vec[0]c=Vector";

    let c = serde_qs::Config::new(0, false);
    let f: Form = c.deserialize_str(s).unwrap();
    dbg!(f);
}