diff --git a/codegen/src/parser/uri_macro.rs b/codegen/src/parser/uri_macro.rs index dffdf8f0..33772d2a 100644 --- a/codegen/src/parser/uri_macro.rs +++ b/codegen/src/parser/uri_macro.rs @@ -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)) } diff --git a/codegen/tests/compile-fail/typed-uris-invalid-syntax.rs b/codegen/tests/compile-fail/typed-uris-invalid-syntax.rs index 124c3b45..eeb84532 100644 --- a/codegen/tests/compile-fail/typed-uris-invalid-syntax.rs +++ b/codegen/tests/compile-fail/typed-uris-invalid-syntax.rs @@ -12,8 +12,10 @@ fn main() { uri!(simple: "Hello", id = 100); //~ ERROR cannot be mixed uri!(simple,); //~ ERROR expected one of `::`, `:`, or `` uri!(simple:); //~ ERROR expected argument list - uri!("mount"); //~ ERROR expected `,`, found `` - uri!("mount",); //~ ERROR expected identifier + uri!("/mount"); //~ ERROR expected `,`, found `` + uri!("/mount",); //~ ERROR expected identifier + uri!("mount", simple); //~ ERROR invalid mount point + uri!("/mount/", simple); //~ ERROR invalid mount point uri!(); //~ ERROR cannot be empty uri!(simple: id = ); //~ ERROR expected argument list //~^ ERROR expected expression