diff options
| -rw-r--r-- | crates/tor-basic-utils/src/rand_hostname.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/tor-basic-utils/src/rand_hostname.rs b/crates/tor-basic-utils/src/rand_hostname.rs index c7c199c1f..3c87bdee4 100644 --- a/crates/tor-basic-utils/src/rand_hostname.rs +++ b/crates/tor-basic-utils/src/rand_hostname.rs @@ -10,7 +10,10 @@ const PREFIXES: &[&str] = &["www."]; const SUFFIXES: &[&str] = &[".com", ".net", ".org"]; /// The characters that we use for the middle part of a hostname. -const CHARSET: &[u8] = b"abcdefghijklmnopqrstuvwxyz-0123456789"; +// NOTE: Some characters have restrictions. +// For example `-` isn't allowed as the first or last character of a subdomain, +// so we don't include it here (see arti#2597). +const CHARSET: &[u8] = b"abcdefghijklmnopqrstuvwxyz0123456789"; /// Lowest permissible hostname length. const MIN_LEN: usize = 16; @@ -74,7 +77,7 @@ mod test { assert!(name.len() >= MIN_LEN); assert!(name.len() <= MAX_LEN); for ch in name.chars() { - assert!(matches!(ch, '.' | '-' | '0'..='9' | 'a'..='z')); + assert!(matches!(ch, '.' | '0'..='9' | 'a'..='z')); } } } |
