mirror of https://github.com/rwf2/Rocket.git
Check mount point validity in 'uri!' macro.
This commit is contained in:
parent
d8acd04789
commit
24f7734c00
|
@ -78,6 +78,12 @@ impl UriParams {
|
|||
Some((symbol, _, _)) => {
|
||||
let string = symbol.as_str();
|
||||
let span = parser.prev_span;
|
||||
if string.contains('<') || !string.starts_with('/') {
|
||||
let mut diag = ecx.struct_span_err(span, "invalid mount point");
|
||||
diag.help("mount points must be static, absolute URIs: `/example`");
|
||||
return Err(diag);
|
||||
}
|
||||
|
||||
parser.expect(&Token::Comma)?;
|
||||
Some(span.wrap(string))
|
||||
}
|
||||
|
|
|
@ -12,8 +12,10 @@ fn main() {
|
|||
uri!(simple: "Hello", id = 100); //~ ERROR cannot be mixed
|
||||
uri!(simple,); //~ ERROR expected one of `::`, `:`, or `<eof>`
|
||||
uri!(simple:); //~ ERROR expected argument list
|
||||
uri!("mount"); //~ ERROR expected `,`, found `<eof>`
|
||||
uri!("mount",); //~ ERROR expected identifier
|
||||
uri!("/mount"); //~ ERROR expected `,`, found `<eof>`
|
||||
uri!("/mount",); //~ ERROR expected identifier
|
||||
uri!("mount", simple); //~ ERROR invalid mount point
|
||||
uri!("/mount/<id>", simple); //~ ERROR invalid mount point
|
||||
uri!(); //~ ERROR cannot be empty
|
||||
uri!(simple: id = ); //~ ERROR expected argument list
|
||||
//~^ ERROR expected expression
|
||||
|
|
Loading…
Reference in New Issue