Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow empty authority in absolute URIs #698

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/uri/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -862,11 +862,6 @@ fn parse_full(mut s: Bytes) -> Result<Uri, InvalidUri> {
});
}

// Authority is required when absolute
if authority_end == 0 {
return Err(ErrorKind::InvalidFormat.into());
}

let authority = s.split_to(authority_end);
let authority = Authority {
data: unsafe { ByteStr::from_utf8_unchecked(authority) },
Expand Down
14 changes: 13 additions & 1 deletion src/uri/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,19 @@ test_parse! {
port = Port::from_str("8008").ok(),
}

test_parse! {
test_file_no_host,
"file:///some/path",
[],

scheme = part!("file"),
authority = None,
host = None,
path = "/some/path",
query = None,
port = None,
}

test_parse! {
test_percentage_encoded_path,
"/echo/abcdefgh_i-j%20/abcdefg_i-j%20478",
Expand Down Expand Up @@ -419,7 +432,6 @@ fn test_uri_parse_error() {
Uri::from_str(s).unwrap_err();
}

err("http://");
err("htt:p//host");
err("hyper.rs/");
err("hyper.rs?key=val");
Expand Down