Rocket version: 0.4
OS: Macos/Ubuntu 14
Some clients url escape before calling a url, but the rocket matcher does not cover these.
E.g. for the url /$world, some clients will create /%24world.
As far as I could tell %24world is also explicitly disallowed, so there is no way to match the route.
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
#[get("/$world")]
fn world() -> &'static str {
"Hello, $world!"
}
fn main() {
rocket::ignite().mount("/", routes![world]).launch();
}
I checked the behaviour in express.js and Spring. The machers there cover both routes /$world and /%24world.
var express = require('express');
var app = express();
app.get('/\\$world', function (req, res) {
res.send('Hello $World!');
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
Rocket should percent decode either during all URI parsing or during route comparison, both of which are very tricky to do correctly. Doing it during parsing would likely also mean changing the Origin URI retrieved via request guard, but I suspect most routes that do care about the request URI would prefer the decoded form.
We could also decode the url if there is a % char in it and then start with the matching. This should work if we internally store only the original route.
Let's work on this in #998.