(
name: &'static str,
value: &str,
max_len: usize,
byte_ok: fn(u8) -> bool,
)
| 891 | } |
| 892 | |
| 893 | fn validate_field( |
| 894 | name: &'static str, |
| 895 | value: &str, |
| 896 | max_len: usize, |
| 897 | byte_ok: fn(u8) -> bool, |
| 898 | ) -> std::result::Result<(), SshSessionResponseError> { |
| 899 | if value.is_empty() { |
| 900 | return Err(SshSessionResponseError::Empty { field: name }); |
| 901 | } |
| 902 | if value.len() > max_len { |
| 903 | return Err(SshSessionResponseError::TooLong { |
| 904 | field: name, |
| 905 | max: max_len, |
| 906 | }); |
| 907 | } |
| 908 | if !value.bytes().all(byte_ok) { |
| 909 | return Err(SshSessionResponseError::InvalidChars { field: name }); |
| 910 | } |
| 911 | Ok(()) |
| 912 | } |
| 913 | |
| 914 | /// Build notes string for a sandbox based on active forwards. |
| 915 | /// |
no test coverage detected