Repository navigation
fix: support IPv6 URLs and reject invalid ports - #15
Conversation
Reviewer's GuideImplementationUpdate URL parsing to recognize bracketed IPv6 hosts and accept only numeric ports within the u16 range.
TestsAdd regression assertions for valid IPv6 URLs and malformed or invalid ports.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/util.rs" line_range="78" />
<code_context>
+ let host_port = authority.rsplit('@').next()?;
+ let host = if let Some(bracketed) = host_port.strip_prefix('[') {
+ let (host, suffix) = bracketed.split_once(']')?;
+ host.parse::<std::net::Ipv6Addr>().ok()?;
+ if !suffix.is_empty() {
+ let port = suffix.strip_prefix(':')?;
</code_context>
<issue_to_address>
**Scoped IPv6 URLs become local paths**
When the input contains a valid percent-encoded IPv6 zone identifier, such as `%25eth0`, `host.parse::<std::net::Ipv6Addr>()` rejects the zone identifier, so `parse_http_url` returns `None`, `is_url` routes the source to the local-file path, and callers report a missing-file error instead of fetching audio.
Validate the IPv6 address separately from its encoded zone identifier and accept valid zone suffixes.
</issue_to_address>
### Comment 2
<location path="src/util.rs" line_range="78" />
<code_context>
+ let host_port = authority.rsplit('@').next()?;
+ let host = if let Some(bracketed) = host_port.strip_prefix('[') {
+ let (host, suffix) = bracketed.split_once(']')?;
+ host.parse::<std::net::Ipv6Addr>().ok()?;
+ if !suffix.is_empty() {
+ let port = suffix.strip_prefix(':')?;
</code_context>
<issue_to_address>
**IPvFuture URLs are rejected**
When the source uses a valid IPvFuture literal, for example `http://[v1.example]/audio.wav`, `host.parse::<std::net::Ipv6Addr>()` rejects valid IPvFuture literals such as `[v1.example]`, so `parse_http_url` returns `None` and callers treat the URL as a local path instead of a URL source.
Accept valid IPvFuture literals as bracketed hosts in addition to IPv6 addresses.
</issue_to_address>Sourcery assessment
Approval pending. 2 findings to address first.
Blocking findings: src/util.rs:78, src/util.rs:78
| let host_port = authority.rsplit('@').next()?; | ||
| let host = if let Some(bracketed) = host_port.strip_prefix('[') { | ||
| let (host, suffix) = bracketed.split_once(']')?; | ||
| host.parse::<std::net::Ipv6Addr>().ok()?; |
There was a problem hiding this comment.
🟡 Medium · Scoped IPv6 URLs become local paths
When the input contains a valid percent-encoded IPv6 zone identifier, such as %25eth0, host.parse::<std::net::Ipv6Addr>() rejects the zone identifier, so parse_http_url returns None, is_url routes the source to the local-file path, and callers report a missing-file error instead of fetching audio.
Validate the IPv6 address separately from its encoded zone identifier and accept valid zone suffixes.
Prompt for AI agents
In `src/util.rs` at line 78:
**Scoped IPv6 URLs become local paths**
When the input contains a valid percent-encoded IPv6 zone identifier, such as `%25eth0`, `host.parse::<std::net::Ipv6Addr>()` rejects the zone identifier, so `parse_http_url` returns `None`, `is_url` routes the source to the local-file path, and callers report a missing-file error instead of fetching audio.
Validate the IPv6 address separately from its encoded zone identifier and accept valid zone suffixes.| let host_port = authority.rsplit('@').next()?; | ||
| let host = if let Some(bracketed) = host_port.strip_prefix('[') { | ||
| let (host, suffix) = bracketed.split_once(']')?; | ||
| host.parse::<std::net::Ipv6Addr>().ok()?; |
There was a problem hiding this comment.
🟡 Medium · IPvFuture URLs are rejected
When the source uses a valid IPvFuture literal, for example http://[v1.example]/audio.wav, host.parse::<std::net::Ipv6Addr>() rejects valid IPvFuture literals such as [v1.example], so parse_http_url returns None and callers treat the URL as a local path instead of a URL source.
Accept valid IPvFuture literals as bracketed hosts in addition to IPv6 addresses.
Prompt for AI agents
In `src/util.rs` at line 78:
**IPvFuture URLs are rejected**
When the source uses a valid IPvFuture literal, for example `http://[v1.example]/audio.wav`, `host.parse::<std::net::Ipv6Addr>()` rejects valid IPvFuture literals such as `[v1.example]`, so `parse_http_url` returns `None` and callers treat the URL as a local path instead of a URL source.
Accept valid IPvFuture literals as bracketed hosts in addition to IPv6 addresses.
Summary
Verification
Summary by Sourcery
Handle bracketed IPv6 URLs correctly and validate URL ports before accepting HTTP(S) sources.
New Features:
Bug Fixes:
Tests: