diff --git a/crates/asn1-parser/tests/decode_encode.rs b/crates/asn1-parser/tests/decode_encode.rs index 33971ad..a397def 100644 --- a/crates/asn1-parser/tests/decode_encode.rs +++ b/crates/asn1-parser/tests/decode_encode.rs @@ -293,3 +293,15 @@ fn test_1() { let asn1 = Asn1::decode_buff(raw).unwrap(); println!("{:?}", asn1); } + +#[test] +fn test_2() { + init_logging(); + + let raw = &[ + 4, 24, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, + ]; + + let asn1 = Asn1::decode_buff(raw).unwrap(); + println!("{:?}", asn1); +} diff --git a/src/asn1/scheme/strings.rs b/src/asn1/scheme/strings.rs index 8fa7250..31b21b5 100644 --- a/src/asn1/scheme/strings.rs +++ b/src/asn1/scheme/strings.rs @@ -39,7 +39,13 @@ pub fn octet_string(props: &OctetStringNodeProps) -> Html { }, None => { let encoded_octets = match std::str::from_utf8(octets) { - Ok(s) => s.to_owned(), + Ok(s) => { + if s.chars().any(|c| (c as u8) < 32) { + hex::encode(octets) + } else { + s.to_owned() + } + } Err(_) => hex::encode(octets), }; html! {