Skip to content

Commit 3144f86

Browse files
committed
remove unsafe block from unicode punycode
1 parent 3e3e2aa commit 3144f86

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

idna/src/punycode.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,10 @@ pub fn encode_str(input: &str) -> Option<String> {
143143
/// 63 encoded bytes, the DNS limit on domain name labels.
144144
pub fn encode(input: &[char]) -> Option<String> {
145145
// Handle "basic" (ASCII) code points. They are encoded as-is.
146-
let output_bytes = input
146+
let mut output : String = input
147147
.iter()
148-
.filter_map(|&c| if c.is_ascii() { Some(c as u8) } else { None })
148+
.filter(|&c| c.is_ascii())
149149
.collect();
150-
let mut output = unsafe { String::from_utf8_unchecked(output_bytes) };
151150
let basic_length = output.len() as u32;
152151
if basic_length > 0 {
153152
output.push_str("-")

0 commit comments

Comments
 (0)