Skip to content

Commit 7ec9c0d

Browse files
committed
fix: narrow cfg gate on extract_host to match call-site condition
1 parent 4ef8747 commit 7ec9c0d

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

src/ssrf.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,10 @@ pub fn validate_url_allowlist(url: &str) -> Result<(), String> {
237237
/// Extract the hostname (without port or brackets) from a URL.
238238
///
239239
/// Returns `None` for malformed URLs or URLs without a `://` scheme separator.
240-
#[cfg(not(feature = "http-allow-all"))]
240+
#[cfg(any(
241+
feature = "http-allow-azure-domains",
242+
feature = "http-allow-test-domains"
243+
))]
241244
fn extract_host(url: &str) -> Option<String> {
242245
// Strip scheme
243246
let after_scheme = url.find("://").map(|i| &url[i + 3..])?;
@@ -555,7 +558,10 @@ mod tests {
555558

556559
// --- extract_host helper ---
557560

558-
#[cfg(not(feature = "http-allow-all"))]
561+
#[cfg(any(
562+
feature = "http-allow-azure-domains",
563+
feature = "http-allow-test-domains"
564+
))]
559565
#[test]
560566
fn extract_host_basic() {
561567
assert_eq!(
@@ -571,7 +577,10 @@ mod tests {
571577
assert_eq!(extract_host("http://user:pass@host/p"), Some("host".into()));
572578
}
573579

574-
#[cfg(not(feature = "http-allow-all"))]
580+
#[cfg(any(
581+
feature = "http-allow-azure-domains",
582+
feature = "http-allow-test-domains"
583+
))]
575584
#[test]
576585
fn extract_host_query_and_fragment() {
577586
// Query-only URL (no path slash after authority)
@@ -601,7 +610,10 @@ mod tests {
601610
);
602611
}
603612

604-
#[cfg(not(feature = "http-allow-all"))]
613+
#[cfg(any(
614+
feature = "http-allow-azure-domains",
615+
feature = "http-allow-test-domains"
616+
))]
605617
#[test]
606618
fn extract_host_none_cases() {
607619
assert_eq!(extract_host("no-scheme"), None);

0 commit comments

Comments
 (0)