mirror of
https://github.com/rwf2/Rocket.git
synced 2025-01-18 23:49:09 +00:00
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]
|
||||
fn absolute_or_authority<'a>(
|
||||
input: &mut RawInput<'a>,
|
||||
) -> Result<'a, Uri<'a>> {
|
||||
fn absolute_or_authority<'a>(input: &mut RawInput<'a>) -> Result<'a, Uri<'a>> {
|
||||
// If the URI begins with `:`, it must follow with a `port`.
|
||||
switch! {
|
||||
peek(b':') => return Ok(Uri::Authority(authority(None)?)),
|
||||
}
|
||||
|
||||
let start = parse_current_marker!();
|
||||
let left = take_while(is_reg_name_char)?;
|
||||
let mark_at_left = parse_current_marker!();
|
||||
|
@ -99,7 +99,18 @@ fn test_assert_no_parse() {
|
||||
|
||||
#[test]
|
||||
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]
|
||||
|
Loading…
Reference in New Issue
Block a user