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/src/util/http_downloader.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'crates/shirabe/src/util/http_downloader.rs') diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs index b055a515..0c91484d 100644 --- a/crates/shirabe/src/util/http_downloader.rs +++ b/crates/shirabe/src/util/http_downloader.rs @@ -18,9 +18,9 @@ use crate::util::sync_executor; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ - InvalidArgumentException, LogicException, PhpMixed, array_replace_recursive, chr, - extension_loaded, file_get_contents, function_exists, implode, is_numeric, php_regex, - rawurldecode, stream_context_create, stripos, strpos, substr, ucfirst, + InvalidArgumentException, LogicException, PhpMixed, array_replace_recursive, extension_loaded, + file_get_contents, function_exists, implode, is_numeric, php_regex, rawurldecode, + stream_context_create, stripos, strpos, substr, ucfirst, }; use shirabe_semver::constraint::SimpleConstraint; @@ -381,11 +381,7 @@ impl HttpDownloader { ) -> anyhow::Result<()> { let clean_message = |msg: &str| -> anyhow::Result { if !io.is_decorated() { - return Ok(Preg::replace( - format!("{{{}{}}}u", chr(27), "\\[[;\\d]*m"), - "", - msg, - )); + return Ok(Preg::replace("{\x1b\\[[;\\d]*m}u", "", msg)); } Ok(msg.to_string()) -- cgit v1.3.1