diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-20 16:51:45 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-20 16:51:45 +0900 |
| commit | a2110fa811c8f6c7d1c45a83c6fd1077eb6f3461 (patch) | |
| tree | 620f3cea4ef0c99b5e4a0b7878a59b9e7dbabe36 /crates/shirabe/src/advisory/audit_config.rs | |
| parent | 37ed5b8c6d4cda30e668d0221eb281431dbc8c67 (diff) | |
| download | php-shirabe-a2110fa811c8f6c7d1c45a83c6fd1077eb6f3461.tar.gz php-shirabe-a2110fa811c8f6c7d1c45a83c6fd1077eb6f3461.tar.zst php-shirabe-a2110fa811c8f6c7d1c45a83c6fd1077eb6f3461.zip | |
fix(php-shim): use PhpMixed::to_bool() for PHP truthy casts
Several call sites coerced PhpMixed to bool via `.as_bool()` (which
only matches a literal Bool variant) where the corresponding PHP code
does a plain `(bool)` cast or truthy check (isset()/array_key_exists()
+ implicit bool conversion). This silently dropped truthy non-bool
values (e.g. String("true"), String("1"), Int(1)) to their unwrap_or
default instead of PHP's actual truthy result. Switched these sites to
PhpMixed::to_bool(), which implements PHP's full truthy-cast rules.
Diffstat (limited to 'crates/shirabe/src/advisory/audit_config.rs')
| -rw-r--r-- | crates/shirabe/src/advisory/audit_config.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crates/shirabe/src/advisory/audit_config.rs b/crates/shirabe/src/advisory/audit_config.rs index e5bf6985..71730317 100644 --- a/crates/shirabe/src/advisory/audit_config.rs +++ b/crates/shirabe/src/advisory/audit_config.rs @@ -168,17 +168,20 @@ impl AuditConfig { let block_insecure = audit_config .and_then(|m| m.get("block-insecure")) - .and_then(|v| v.as_bool()) + .and_then(|v| v.as_opt()) + .map(|v| v.to_bool()) .unwrap_or(true); let block_abandoned = audit_config .and_then(|m| m.get("block-abandoned")) - .and_then(|v| v.as_bool()) + .and_then(|v| v.as_opt()) + .map(|v| v.to_bool()) .unwrap_or(false); let ignore_unreachable = audit_config .and_then(|m| m.get("ignore-unreachable")) - .and_then(|v| v.as_bool()) + .and_then(|v| v.as_opt()) + .map(|v| v.to_bool()) .unwrap_or(false); Ok(Self::new( |
