mirror of https://github.com/rwf2/Rocket.git
Reject invalid URIs that begin with ':'.
This commit is contained in:
parent
068aacd79d
commit
3c8f5708ea
|
@ -141,9 +141,12 @@ pub fn absolute_only<'a>(input: &mut RawInput<'a>) -> Result<'a, Absolute<'a>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[parser]
|
#[parser]
|
||||||
fn absolute_or_authority<'a>(
|
fn absolute_or_authority<'a>(input: &mut RawInput<'a>) -> Result<'a, Uri<'a>> {
|
||||||
input: &mut RawInput<'a>,
|
// If the URI begins with `:`, it must follow with a `port`.
|
||||||
) -> Result<'a, Uri<'a>> {
|
switch! {
|
||||||
|
peek(b':') => return Ok(Uri::Authority(authority(None)?)),
|
||||||
|
}
|
||||||
|
|
||||||
let start = parse_current_marker!();
|
let start = parse_current_marker!();
|
||||||
let left = take_while(is_reg_name_char)?;
|
let left = take_while(is_reg_name_char)?;
|
||||||
let mark_at_left = parse_current_marker!();
|
let mark_at_left = parse_current_marker!();
|
||||||
|
|
|
@ -99,7 +99,18 @@ fn test_assert_no_parse() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bad_parses() {
|
fn bad_parses() {
|
||||||
assert_no_parse!("://z7:77777777777777777777777777777`77777777777");
|
assert_no_parse! {
|
||||||
|
"://z7:77777777777777777777777777777`77777777777",
|
||||||
|
|
||||||
|
// from #1621
|
||||||
|
"://@example.com/test",
|
||||||
|
"://example.com:/test",
|
||||||
|
"://@example.com:/test",
|
||||||
|
"://example.com/test?",
|
||||||
|
"://example.com:/test?",
|
||||||
|
"://@example.com/test?",
|
||||||
|
"://@example.com:/test?"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue