Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ impl test_programs::p3::exports::wasi::cli::run::Guest for Component {
assert!(req.set_authority(Some("bad-port:99999")).is_err());
assert!(req.set_authority(Some("bad-\nhost")).is_err());
assert!(req.set_authority(Some("too-many-ports:80:80:80")).is_err());
// IPv6 addresses with and without a port should be allowed.
assert!(req.set_authority(Some("[::]:443")).is_ok());
assert!(req.set_authority(Some("[::]")).is_ok());

assert!(
req.set_scheme(Some(&Scheme::Other("bad\nscheme".to_string())))
Expand Down
5 changes: 4 additions & 1 deletion crates/wasi-http/src/p3/host/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,10 @@ impl HostRequest for WasiHttpCtxView<'_> {
req.authority = None;
return Ok(Ok(()));
};
let has_port = authority.contains(':');
let has_port = match authority.rsplit_once(']') {
Some((_, suffix)) => suffix.starts_with(':'),
None => authority.contains(':'),
};
let Ok(authority) = http::uri::Authority::try_from(authority) else {
return Ok(Err(()));
};
Expand Down
Loading