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/http_downloader.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 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 8210a5c4..f022ef4e 100644 --- a/crates/shirabe/src/util/http_downloader.rs +++ b/crates/shirabe/src/util/http_downloader.rs @@ -19,7 +19,7 @@ use indexmap::IndexMap; use shirabe_php_shim::Catch as _; use shirabe_php_shim::{ InvalidArgumentException, LogicException, PhpMixed, array_replace_recursive, extension_loaded, - file_get_contents, function_exists, implode, is_numeric, php_regex, preg_match2, preg_replace, + file_get_contents, function_exists, implode, is_numeric, php_regex, preg_match, preg_replace, rawurldecode, stream_context_create, stripos, strpos, substr, ucfirst, }; use shirabe_semver::constraint::SimpleConstraint; @@ -239,11 +239,7 @@ impl HttpDownloader { let origin = Url::get_origin(&self.config.borrow(), url); // capture username/password from URL if there is one - if let Some(m) = preg_match2( - php_regex!(r"{^https?://([^:/]+):([^@/]+)@([^/]+)}i"), - url, - 0, - ) { + if let Some(m) = preg_match(php_regex!(r"{^https?://([^:/]+):([^@/]+)@([^/]+)}i"), url) { self.io.borrow_mut().set_authentication( origin.clone(), rawurldecode(m.get(1).unwrap_or_default().to_string().as_str()), @@ -489,7 +485,7 @@ impl HttpDownloader { return false; } - if preg_match2(php_regex!(r"{^https?://}i"), url, 0).is_none() { + if preg_match(php_regex!(r"{^https?://}i"), url).is_none() { return false; } -- cgit v1.3.1-4-g156e