Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(config): an @ after the query or fragment is not userinfo in host_of

M3gA-Mind1062ae4529db
diff --git a/crates/openhuman-core/src/config/schema/resolved_endpoints.rs b/crates/openhuman-core/src/config/schema/resolved_endpoints.rs
index b61b136768..402f784351 100644
--- a/crates/openhuman-core/src/config/schema/resolved_endpoints.rs
+++ b/crates/openhuman-core/src/config/schema/resolved_endpoints.rs
@@ -103,7 +103,12 @@ impl ResolvedEndpoints {
fn host_of(url: &str) -> String {
let lower = url.trim().to_ascii_lowercase();
let without_scheme = lower.split("://").nth(1).unwrap_or(&lower);
- let authority = without_scheme.split('/').next().unwrap_or("");
+ // The authority ends at the path, query or fragment (a backslash is a path
+ // separator for http(s)), so an `@` after any of them is not userinfo.
+ let authority = without_scheme
+ .split(['/', '\\', '?', '#'])
+ .next()
+ .unwrap_or("");
let host = authority.split('@').next_back().unwrap_or(authority);
host.split(':').next().unwrap_or(host).to_string()
}
diff --git a/crates/openhuman-core/src/config/schema/resolved_endpoints_tests.rs b/crates/openhuman-core/src/config/schema/resolved_endpoints_tests.rs
index 09eb8f9345..5275a9c799 100644
--- a/crates/openhuman-core/src/config/schema/resolved_endpoints_tests.rs
+++ b/crates/openhuman-core/src/config/schema/resolved_endpoints_tests.rs
@@ -33,3 +33,12 @@ fn lookalikes_and_path_mentions_do_not_match() {
assert!(!e.is_managed_host("https://other.invalid/api.example.test"));
assert!(!e.is_managed_host(""));
}
+
+#[test]
+fn an_at_sign_after_the_query_fragment_or_path_is_not_userinfo() {
+ let e = endpoints();
+ assert!(!e.is_managed_host("https://[email protected]/v1"));
+ assert!(!e.is_managed_host("https://evil.invalid#@api.example.test/v1"));
+ assert!(!e.is_managed_host("https://evil.invalid\\@api.example.test/v1"));
+ assert!(e.is_managed_host("https://[email protected]"));
+}