From 5ef607e2afe7eaf7e2ccdf62f3ffacfede3c5fca Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 20 Jul 2026 17:10:49 +0900 Subject: fix(no-proxy-pattern): stop chr() corrupting IP bytes as lossy UTF-8 shirabe_php_shim::chr() returned a Rust String, which lossily re-encodes bytes >= 0x80 as UTF-8 replacement characters. ip_get_mask, ip_get_network, and ip_map_to_6 relied on chr() to build raw in_addr and netmask byte arrays, corrupting IPv4-in-IPv6 mappings and CIDR netmasks. Build the Vec byte arrays directly instead of round-tripping through String, and un-ignore test_ip_address and test_ip_range now that the underlying bug is fixed. chr()'s only other caller (http_downloader.rs, an ASCII ESC byte in a regex pattern) didn't need the indirection either, so remove the shim function entirely. Co-Authored-By: Claude Sonnet 5 --- crates/shirabe/tests/util/no_proxy_pattern_test.rs | 2 -- 1 file changed, 2 deletions(-) (limited to 'crates/shirabe/tests/util/no_proxy_pattern_test.rs') diff --git a/crates/shirabe/tests/util/no_proxy_pattern_test.rs b/crates/shirabe/tests/util/no_proxy_pattern_test.rs index e59e28a6..63f0d5f6 100644 --- a/crates/shirabe/tests/util/no_proxy_pattern_test.rs +++ b/crates/shirabe/tests/util/no_proxy_pattern_test.rs @@ -42,7 +42,6 @@ fn test_host_name() { } #[test] -#[ignore = "shirabe_php_shim::chr() lossily re-encodes bytes >= 0x80 as UTF-8 (TODO(phase-d) in its own doc comment); ip_map_to_6's chr(255) filler bytes become 3-byte U+FFFD replacements, corrupting the mapped IPv4-in-IPv6 byte arrays used for comparison"] fn test_ip_address() { let noproxy = "192.168.1.1, 2001:db8::52:0:1"; @@ -55,7 +54,6 @@ fn test_ip_address() { } #[test] -#[ignore = "shirabe_php_shim::chr() lossily re-encodes bytes >= 0x80 as UTF-8 (TODO(phase-d) in its own doc comment); ip_get_mask's chr(255)/chr(0xff^...) calls corrupt the CIDR netmask bytes used in match_range, breaking all prefix-based no_proxy matching"] fn test_ip_range() { let noproxy = "10.0.0.0/30, 2002:db8:a::45/121"; -- cgit v1.3.1