Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion wacore/binary/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ impl<'a> Decoder<'a> {
unpacked_bytes.pop();
}

String::from_utf8(unpacked_bytes).map_err(|e| BinaryError::InvalidUtf8(e.utf8_error()))
// SAFETY: unpacked bytes are built exclusively from protocol lookup tables:
// - HEX_8 produces ASCII '0'..'9' and 'A'..'F'
// - NIBBLE_8 produces ASCII '0'..'9', '-', '.', or '\0' padding
// All generated bytes are valid UTF-8 scalar values.
Ok(unsafe { String::from_utf8_unchecked(unpacked_bytes) })
}

fn unpack_byte(tag: u8, value: u8) -> Result<char> {
Expand Down
Loading