From e093b2be1c333e67c96aebb0a5291bea9ae3d6db Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 18 Aug 2026 01:57:02 +0900 Subject: refactor(preg): drop the offset argument from preg_match Every call site but one passed offset 0. The remaining one, the UTF-8 chunking loop in Application, slices the subject instead: its pattern has no anchor or lookaround, so matching a suffix is equivalent to starting the search at that offset. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/util/remote_filesystem.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'crates/shirabe/src/util/remote_filesystem.rs') diff --git a/crates/shirabe/src/util/remote_filesystem.rs b/crates/shirabe/src/util/remote_filesystem.rs index 7af5473a..a7901567 100644 --- a/crates/shirabe/src/util/remote_filesystem.rs +++ b/crates/shirabe/src/util/remote_filesystem.rs @@ -19,7 +19,7 @@ use shirabe_php_shim::{ STREAM_NOTIFY_PROGRESS, array_replace_recursive, base64_encode, explode, extension_loaded, file_get_contents, file_get_contents5, file_put_contents, filter_var_boolean, gethostbyname, http_clear_last_response_headers, http_get_last_response_headers, ini_get, json_decode_assoc, - parse_url, php_regex, preg_match2, preg_quote, preg_replace, strpos, strtolower, strtr, substr, + parse_url, php_regex, preg_match, preg_quote, preg_replace, strpos, strtolower, strtr, substr, trim, zlib_decode, }; @@ -148,7 +148,7 @@ impl RemoteFilesystem { pub fn find_status_code(headers: &[String]) -> Option { let mut value: Option = None; for header in headers { - if let Some(m) = preg_match2(php_regex!("{^HTTP/\\S+ (\\d+)}i"), header, 0) { + if let Some(m) = preg_match(php_regex!("{^HTTP/\\S+ (\\d+)}i"), header) { value = m.get(1).and_then(|s| s.parse().ok()).or(Some(0)); } } @@ -159,7 +159,7 @@ impl RemoteFilesystem { pub fn find_status_message(&self, headers: &[String]) -> Option { let mut value: Option = None; for header in headers { - if preg_match2(php_regex!("{^HTTP/\\S+ \\d+}i"), header, 0).is_some() { + if preg_match(php_regex!("{^HTTP/\\S+ \\d+}i"), header).is_some() { value = Some(header.clone()); } } @@ -285,10 +285,9 @@ impl RemoteFilesystem { crate::io::DEBUG, ); - if (preg_match2( + if (preg_match( php_regex!("{^http://(repo\\.)?packagist\\.org/p/}"), &file_url, - 0, ) .is_none() || (strpos(&file_url, "$").is_none() && strpos(&file_url, "%24").is_none())) @@ -475,10 +474,9 @@ impl RemoteFilesystem { None, ) != ".zip") && content_type.is_some() - && preg_match2( + && preg_match( php_regex!("{^text/html\\b}i"), content_type.as_deref().unwrap_or(""), - 0, ) .is_some(); if bitbucket_login_match { -- cgit v1.3.1-4-g156e