diff options
Diffstat (limited to 'crates/shirabe/src/util')
| -rw-r--r-- | crates/shirabe/src/util/filesystem.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/git.rs | 30 | ||||
| -rw-r--r-- | crates/shirabe/src/util/github.rs | 4 | ||||
| -rw-r--r-- | crates/shirabe/src/util/http_downloader.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/process_executor.rs | 3 | ||||
| -rw-r--r-- | crates/shirabe/src/util/remote_filesystem.rs | 4 |
6 files changed, 17 insertions, 28 deletions
diff --git a/crates/shirabe/src/util/filesystem.rs b/crates/shirabe/src/util/filesystem.rs index f693598..15f970d 100644 --- a/crates/shirabe/src/util/filesystem.rs +++ b/crates/shirabe/src/util/filesystem.rs @@ -701,7 +701,7 @@ impl Filesystem { shirabe_external_packages::composer::pcre::CaptureKey, String, > = indexmap::IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( "{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix", &path, Some(&mut prefix_match), diff --git a/crates/shirabe/src/util/git.rs b/crates/shirabe/src/util/git.rs index d9cfdfd..35f4940 100644 --- a/crates/shirabe/src/util/git.rs +++ b/crates/shirabe/src/util/git.rs @@ -227,7 +227,7 @@ impl Git { cwd.map(|s| s.to_string()), ); let mut m: IndexMap<CaptureKey, String> = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( r"{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im", &output, Some(&mut m), @@ -251,7 +251,7 @@ impl Git { // public github, autoswitch protocols // @phpstan-ignore composerPcre.maybeUnsafeStrictGroups let mut m: IndexMap<CaptureKey, String> = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( &format!( "{{^(?:https?|git)://{}/(.*)}}", Self::get_github_domains_regex(&*self.config.borrow()) @@ -361,7 +361,7 @@ impl Git { // private github repository without ssh key access, try https with auth // @phpstan-ignore composerPcre.maybeUnsafeStrictGroups let mut m: IndexMap<CaptureKey, String> = IndexMap::new(); - let github_matched = Preg::is_match_strict_groups3( + let github_matched = Preg::is_match3( &format!( "{{^git@{}:(.+?)\\.git$}}i", Self::get_github_domains_regex(&*self.config.borrow()) @@ -370,7 +370,7 @@ impl Git { Some(&mut m), ) .unwrap_or(false) - || Preg::is_match_strict_groups3( + || Preg::is_match3( &format!( "{{^https?://{}/(.*?)(?:\\.git)?$}}i", Self::get_github_domains_regex(&*self.config.borrow()) @@ -430,13 +430,13 @@ impl Git { error_msg = self.process.borrow().get_error_output().to_string(); } } else if { - let bb_matched = Preg::is_match_strict_groups3( + let bb_matched = Preg::is_match3( r"{^(https?)://(bitbucket\.org)/(.*?)(?:\.git)?$}i", url, Some(&mut m), ) .unwrap_or(false) - || Preg::is_match_strict_groups3( + || Preg::is_match3( r"{^(git)@(bitbucket\.org):(.+?\.git)$}i", url, Some(&mut m), @@ -582,7 +582,7 @@ impl Git { error_msg = self.process.borrow().get_error_output().to_string(); } else if { - let gl_matched = Preg::is_match_strict_groups3( + let gl_matched = Preg::is_match3( &format!( "{{^(git)@{}:(.+?\\.git)$}}i", Self::get_gitlab_domains_regex(&*self.config.borrow()) @@ -591,7 +591,7 @@ impl Git { Some(&mut m), ) .unwrap_or(false) - || Preg::is_match_strict_groups3( + || Preg::is_match3( &format!( "{{^(https?)://{}/(.*)}}i", Self::get_gitlab_domains_regex(&*self.config.borrow()) @@ -1117,9 +1117,7 @@ impl Git { /// @return array<int, string>|null fn get_authentication_failure(&self, url: &str) -> Option<IndexMap<CaptureKey, String>> { let mut m: IndexMap<CaptureKey, String> = IndexMap::new(); - if !Preg::is_match_strict_groups3(r"{^(https?://)([^/]+)(.*)$}i", url, Some(&mut m)) - .unwrap_or(false) - { + if !Preg::is_match3(r"{^(https?://)([^/]+)(.*)$}i", url, Some(&mut m)).unwrap_or(false) { return None; } @@ -1204,12 +1202,8 @@ impl Git { .split_lines(output_mixed.as_string().unwrap_or("")); for line in lines { let mut matches: IndexMap<CaptureKey, String> = IndexMap::new(); - if Preg::is_match_strict_groups3( - r"{^\s*HEAD branch:\s(.+)\s*$}m", - &line, - Some(&mut matches), - ) - .unwrap_or(false) + if Preg::is_match3(r"{^\s*HEAD branch:\s(.+)\s*$}m", &line, Some(&mut matches)) + .unwrap_or(false) { return Ok(Some( matches @@ -1347,7 +1341,7 @@ impl Git { ); if exit_code == 0 { let mut matches: IndexMap<CaptureKey, String> = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( r"/^git version (\d+(?:\.\d+)+)/m", &output, Some(&mut matches), diff --git a/crates/shirabe/src/util/github.rs b/crates/shirabe/src/util/github.rs index 26544cb..1cd78c1 100644 --- a/crates/shirabe/src/util/github.rs +++ b/crates/shirabe/src/util/github.rs @@ -333,9 +333,7 @@ impl GitHub { continue; } let mut caps: IndexMap<CaptureKey, String> = IndexMap::new(); - if Preg::match_strict_groups3(r"{\burl=(?P<url>[^\s;]+)}", header, Some(&mut caps)) - .unwrap_or(false) - { + if Preg::match3(r"{\burl=(?P<url>[^\s;]+)}", header, Some(&mut caps)).unwrap_or(false) { return caps.get(&CaptureKey::ByName("url".to_string())).cloned(); } } diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs index 434dedb..b1da08f 100644 --- a/crates/shirabe/src/util/http_downloader.rs +++ b/crates/shirabe/src/util/http_downloader.rs @@ -310,7 +310,7 @@ impl HttpDownloader { // capture username/password from URL if there is one let mut m: IndexMap<CaptureKey, String> = IndexMap::new(); - if Preg::is_match_strict_groups3( + if Preg::is_match3( r"{^https?://([^:/]+):([^@/]+)@([^/]+)}i", &request.url, Some(&mut m), diff --git a/crates/shirabe/src/util/process_executor.rs b/crates/shirabe/src/util/process_executor.rs index 75b40cb..a681f2c 100644 --- a/crates/shirabe/src/util/process_executor.rs +++ b/crates/shirabe/src/util/process_executor.rs @@ -206,8 +206,7 @@ impl ProcessExecutor { let mut command_str = command.as_string().unwrap_or("").to_string(); if Platform::is_windows() { let mut m: IndexMap<CaptureKey, String> = IndexMap::new(); - if Preg::is_match_strict_groups3(r"{^([^:/\\]++) }", &command_str, Some(&mut m)) - .unwrap_or(false) + if Preg::is_match3(r"{^([^:/\\]++) }", &command_str, Some(&mut m)).unwrap_or(false) { let m1 = m.get(&CaptureKey::ByIndex(1)).cloned().unwrap_or_default(); command_str = substr_replace( diff --git a/crates/shirabe/src/util/remote_filesystem.rs b/crates/shirabe/src/util/remote_filesystem.rs index c510d7c..a75f947 100644 --- a/crates/shirabe/src/util/remote_filesystem.rs +++ b/crates/shirabe/src/util/remote_filesystem.rs @@ -145,9 +145,7 @@ impl RemoteFilesystem { let mut value: Option<i64> = None; for header in headers { let mut m: IndexMap<CaptureKey, String> = IndexMap::new(); - if Preg::is_match_strict_groups3("{^HTTP/\\S+ (\\d+)}i", header, Some(&mut m)) - .unwrap_or(false) - { + if Preg::is_match3("{^HTTP/\\S+ (\\d+)}i", header, Some(&mut m)).unwrap_or(false) { value = m .get(&CaptureKey::ByIndex(1)) .and_then(|s| s.parse().ok()) |
