2018-10-05 04:44:42 +00:00
|
|
|
#[macro_use] extern crate rocket;
|
|
|
|
|
|
|
|
// Check that route paths are absolute and normalized.
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("a")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn f0() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn f1() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("a/b/c")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn f2() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/a///b")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn f3() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/?bat&&")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn f4() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/?bat&&")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn f5() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/a/b//")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn f6() {}
|
|
|
|
|
|
|
|
// Check that paths contain only valid URI characters
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/!@#$%^&*()")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn g1() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/a%20b")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn g2() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/a?a%20b")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn g3() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/a?a+b")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn g4() {}
|
|
|
|
|
|
|
|
// Check that all declared parameters are accounted for
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/<name>")]
|
|
|
|
fn h0(_name: usize) {}
|
2018-10-05 04:44:42 +00:00
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/a?<r>")]
|
|
|
|
fn h1() {}
|
2018-10-05 04:44:42 +00:00
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[post("/a", data = "<test>")]
|
|
|
|
fn h2() {}
|
2018-10-05 04:44:42 +00:00
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/<_r>")]
|
|
|
|
fn h3() {}
|
|
|
|
|
|
|
|
#[get("/<_r>/<b>")]
|
|
|
|
fn h4() {}
|
2018-10-05 04:44:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Check dynamic parameters are valid idents
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/<foo_.>")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn i0() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/<foo*>")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn i1() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/<!>")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn i2() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/<name>:<id>")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn i3() {}
|
|
|
|
|
|
|
|
// Check that a data parameter is exactly `<param>`
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", data = "foo")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn j0() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", data = "<foo..>")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn j1() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", data = "<foo")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn j2() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/", data = "<test >")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn j3() {}
|
|
|
|
|
|
|
|
// Check that all identifiers are named
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/<_>")]
|
|
|
|
fn k0(_: usize) {}
|
2018-10-05 04:44:42 +00:00
|
|
|
|
|
|
|
// Check that strange dynamic syntax is caught.
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/<>")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn m0() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/<id><")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn m1() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/<<<<id><")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn m2() {}
|
|
|
|
|
2020-07-21 17:23:59 +00:00
|
|
|
#[get("/<>name><")]
|
2018-10-05 04:44:42 +00:00
|
|
|
fn m3() {}
|
|
|
|
|
|
|
|
fn main() { }
|