aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-17 04:27:46 +0900
committernsfisis <nsfisis@gmail.com>2026-08-17 04:27:46 +0900
commitd28eefe6833e44db89a27e6afb5f15fc5d667b9b (patch)
tree10044b08482eadcb69b48f1cab3632f17f6d3fc8 /crates/shirabe
parent704ba2d87733657dea852fa697fc6d23a961a71b (diff)
downloadphp-shirabe-d28eefe6833e44db89a27e6afb5f15fc5d667b9b.tar.gz
php-shirabe-d28eefe6833e44db89a27e6afb5f15fc5d667b9b.tar.zst
php-shirabe-d28eefe6833e44db89a27e6afb5f15fc5d667b9b.zip
fix(no-proxy-pattern): drop empty entries when splitting NO_PROXY
The PHP splits with PREG_SPLIT_NO_EMPTY, but the port dropped that flag, so a leading separator in NO_PROXY kept an empty first entry. That made "empty($hostNames) || '*' === $hostNames[0]" false for values such as " *", turning "bypass the proxy for every host" into "use the proxy for every host". Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe')
-rw-r--r--crates/shirabe/src/util/no_proxy_pattern.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/crates/shirabe/src/util/no_proxy_pattern.rs b/crates/shirabe/src/util/no_proxy_pattern.rs
index cd54fa1a..4f2809e7 100644
--- a/crates/shirabe/src/util/no_proxy_pattern.rs
+++ b/crates/shirabe/src/util/no_proxy_pattern.rs
@@ -36,8 +36,10 @@ pub struct IpData {
impl NoProxyPattern {
/// @param string $pattern NO_PROXY pattern
pub fn new(pattern: &str) -> Self {
- // PHP: Preg::split('{[\s,]+}', $pattern, -1, PREG_SPLIT_NO_EMPTY)
- let host_names = preg_split(php_regex!(r"{[\s,]+}"), pattern);
+ let host_names: Vec<String> = preg_split(php_regex!(r"{[\s,]+}"), pattern)
+ .into_iter()
+ .filter(|host_name| !host_name.is_empty())
+ .collect();
let noproxy = host_names.is_empty() || host_names[0] == "*";
Self {
host_names,