fix(python): split PIP_TRUSTED_HOST by whitespace to support multiple hosts (#9675)

* fix(python): split PIP_TRUSTED_HOST by whitespace for multiple hosts

When PIP_TRUSTED_HOST contains multiple space-separated hostnames, the
whole string was passed as a single --trusted-host argument
(--trusted-host "host1 host2") rather than one flag per host. This
matches pip's documented PIP_TRUSTED_HOST convention by emitting a
separate --trusted-host for each host, mirroring the existing
pip_extra_index_url handling.

Fixes WIN-2077

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(python): use shell word-splitting for nsjail trusted-host args

Address review feedback: the previous tr/sed pipeline only split on
single spaces, diverging from the Rust split_whitespace() paths. Repeated
or leading/trailing spaces produced empty --trusted-host flags and
tab-separated hosts were not split. Use an unquoted for-loop over
$TRUSTED_HOST so the shell's own IFS word-splitting handles arbitrary
whitespace and skips empty fields, matching the non-nsjail paths.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ruben Fiszel
2026-06-19 12:59:08 +00:00
committed by GitHub
co-authored by Claude Opus 4.8
parent 9add719d93
commit cafb473494
2 changed files with 8 additions and 3 deletions
@@ -361,7 +361,9 @@ pub async fn uv_pip_compile(
args.extend(["--index-url", url]);
}
if let Some(host) = TRUSTED_HOST.as_ref() {
args.extend(["--trusted-host", host]);
host.split_whitespace().for_each(|h| {
args.extend(["--trusted-host", h]);
});
}
if let Some(cert_path) = INDEX_CERT.as_ref() {
args.extend(["--cert", cert_path]);
@@ -2192,7 +2194,9 @@ async fn spawn_uv_install(
command_args.extend(["--index-url", url]);
}
if let Some(host) = TRUSTED_HOST.as_ref() {
command_args.extend(["--trusted-host", &host]);
host.split_whitespace().for_each(|h| {
command_args.extend(["--trusted-host", h]);
});
}
if *NATIVE_CERT {
command_args.extend(["--native-tls"]);