diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-18 01:57:02 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-18 01:57:02 +0900 |
| commit | e093b2be1c333e67c96aebb0a5291bea9ae3d6db (patch) | |
| tree | 0743fad689f419959c3a898605e21485087884fa /crates/shirabe/src/util/remote_filesystem.rs | |
| parent | 050c56ef263d90d862ef565bc1762909110e02eb (diff) | |
| download | php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.tar.gz php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.tar.zst php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/util/remote_filesystem.rs')
| -rw-r--r-- | crates/shirabe/src/util/remote_filesystem.rs | 12 |
1 files changed, 5 insertions, 7 deletions
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<i64> { let mut value: Option<i64> = 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<String> { let mut value: Option<String> = 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 { |
