diff options
Diffstat (limited to 'crates/shirabe/src/util')
| -rw-r--r-- | crates/shirabe/src/util/auth_helper.rs | 11 | ||||
| -rw-r--r-- | crates/shirabe/src/util/gitlab.rs | 5 | ||||
| -rw-r--r-- | crates/shirabe/src/util/http/curl_downloader.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/src/util/perforce.rs | 4 | ||||
| -rw-r--r-- | crates/shirabe/src/util/remote_filesystem.rs | 4 |
5 files changed, 14 insertions, 12 deletions
diff --git a/crates/shirabe/src/util/auth_helper.rs b/crates/shirabe/src/util/auth_helper.rs index 3b8aa2e7..7d47f088 100644 --- a/crates/shirabe/src/util/auth_helper.rs +++ b/crates/shirabe/src/util/auth_helper.rs @@ -12,7 +12,8 @@ use indexmap::IndexMap; use shirabe_pcre::Preg; use shirabe_php_shim::{ PhpMixed, RuntimeException, base64_encode, explode, in_array_loose, in_array_strict, is_array, - is_string, json_decode, parse_url, php_regex, str_replace, strpos, strtolower, substr, trim, + is_string, json_decode_assoc, parse_url, php_regex, str_replace, strpos, strtolower, substr, + trim, }; #[derive(Debug)] @@ -189,7 +190,7 @@ impl AuthHelper { // Try to extract a more specific error message from GitHub's API response let mut git_hub_api_message: Option<String> = None; if let Some(body) = response_body { - let decoded = json_decode(body, true)?; + let decoded = json_decode_assoc(body)?; if is_array(&decoded) && let Some(arr) = decoded.as_array() && let Some(msg) = arr.get("message") @@ -520,7 +521,7 @@ impl AuthHelper { let mut custom_headers: PhpMixed = PhpMixed::Null; // PHP: if (is_string($auth['username'])) // username field is always String in our IndexMap representation - custom_headers = json_decode(&username, true)?; + custom_headers = json_decode_assoc(&username)?; if is_array(&custom_headers) { if let Some(arr) = custom_headers.as_array() { for header in arr.values() { @@ -580,12 +581,12 @@ impl AuthHelper { Some("Using Bitbucket OAuth token authentication".to_string()); } } else if username == "client-certificate" { - // PHP: $options['ssl'] = array_merge($options['ssl'] ?? [], json_decode((string) $auth['password'], true)); + // PHP: $options['ssl'] = array_merge($options['ssl'] ?? [], json_decode_assoc((string) $auth['password'])); let existing_ssl = options .get("ssl") .cloned() .unwrap_or(PhpMixed::Array(IndexMap::new())); - let decoded = json_decode(&password, true)?; + let decoded = json_decode_assoc(&password)?; options.insert( "ssl".to_string(), shirabe_php_shim::array_merge(existing_ssl, decoded), diff --git a/crates/shirabe/src/util/gitlab.rs b/crates/shirabe/src/util/gitlab.rs index ef68c82f..52707b5b 100644 --- a/crates/shirabe/src/util/gitlab.rs +++ b/crates/shirabe/src/util/gitlab.rs @@ -12,7 +12,8 @@ use indexmap::IndexMap; use shirabe_pcre::Preg; use shirabe_php_shim::Catch as _; use shirabe_php_shim::{ - PhpMixed, RuntimeException, http_build_query, in_array_strict, json_decode, php_regex, time, + PhpMixed, RuntimeException, http_build_query, in_array_strict, json_decode_assoc, php_regex, + time, }; #[derive(Debug)] @@ -253,7 +254,7 @@ impl GitLab { Some(te) if te.get_code() == 403 || te.get_code() == 401 => { if te.get_code() == 401 { let response = - te.get_response().and_then(|r| json_decode(r, true).ok()); + te.get_response().and_then(|r| json_decode_assoc(r).ok()); let is_invalid_grant = response .as_ref() .and_then(|r| r.as_array()) diff --git a/crates/shirabe/src/util/http/curl_downloader.rs b/crates/shirabe/src/util/http/curl_downloader.rs index 742e0fd3..6140bb08 100644 --- a/crates/shirabe/src/util/http/curl_downloader.rs +++ b/crates/shirabe/src/util/http/curl_downloader.rs @@ -339,7 +339,7 @@ impl CurlDownloader { && curl_response.inner.get_header("content-type").as_deref() == Some("application/json") && let Some(body) = curl_response.inner.get_body() { - let decoded = shirabe_php_shim::json_decode(body, true)?; + let decoded = shirabe_php_shim::json_decode_assoc(body)?; if let PhpMixed::Array(a) = decoded { HttpDownloader::output_warnings(self.io.clone(), origin, &a)?; } diff --git a/crates/shirabe/src/util/perforce.rs b/crates/shirabe/src/util/perforce.rs index fbab6889..c0cd5a08 100644 --- a/crates/shirabe/src/util/perforce.rs +++ b/crates/shirabe/src/util/perforce.rs @@ -9,7 +9,7 @@ use indexmap::IndexMap; use shirabe_pcre::Preg; use shirabe_php_shim::{ Exception, PHP_EOL, PhpMixed, PhpResource, chdir, date_local, explode, fclose, feof, fgets, - file_get_contents, fopen, fwrite, gethostname, json_decode, php_regex, str_replace_array, + file_get_contents, fopen, fwrite, gethostname, json_decode_assoc, php_regex, str_replace_array, strcmp, strlen, strpos, strrpos, substr, time, trim, }; use shirabe_symfony_process::ExecutableFinder; @@ -577,7 +577,7 @@ impl Perforce { Some(s) => s, }; - let decoded = json_decode(&composer_file_content, true)?; + let decoded = json_decode_assoc(&composer_file_content)?; Ok(match decoded { PhpMixed::Array(m) => Some(m.into_iter().collect()), _ => None, diff --git a/crates/shirabe/src/util/remote_filesystem.rs b/crates/shirabe/src/util/remote_filesystem.rs index 61165b28..4a8ca267 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::{ PhpMixed, RuntimeException, STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_FILE_SIZE_IS, 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, + http_clear_last_response_headers, http_get_last_response_headers, ini_get, json_decode_assoc, parse_url, php_regex, preg_quote, strpos, strtolower, strtr, substr, trim, zlib_decode, }; @@ -336,7 +336,7 @@ impl RemoteFilesystem { { let parsed = result .as_deref() - .map(|s| json_decode(s, true).unwrap_or(PhpMixed::Null)) + .map(|s| json_decode_assoc(s).unwrap_or(PhpMixed::Null)) .unwrap_or(PhpMixed::Null); let parsed_map: IndexMap<String, PhpMixed> = match parsed { PhpMixed::Array(m) => m.into_iter().collect(), |
