Skip to content
9 changes: 8 additions & 1 deletion src/boringssl/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,11 +578,18 @@
/// Certificate name bytes (IA5 / Latin-1) for error messages.
struct NameBytes<'a>(&'a [u8]);

/// Node's `IsSafeAltName` (see `src/jsc/bindings/ncrypto.cpp`).
#[inline]
fn is_safe_alt_name(name: &[u8]) -> bool {
name.iter()
.all(|&c| (b' '..=b'~').contains(&c) && !matches!(c, b'"' | b'\\' | b',' | b'\''))
}

impl core::fmt::Display for NameBytes<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
use core::fmt::Write;
if X509::is_safe_alt_name(self.0, false) {
if is_safe_alt_name(self.0) {
for &byte in self.0 {

Check failure on line 592 in src/boringssl/lib.rs

View workflow job for this annotation

GitHub Actions / cargo clippy

the name `is_safe_alt_name` is defined multiple times
f.write_char(char::from(byte))?;
}
return Ok(());
Expand Down
Loading
Loading