From 8d56a743153d739c7ea90953c3892d8e82e6215b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carles=20Barrobe=CC=81s?= Date: Fri, 8 Oct 2021 10:05:22 +0200 Subject: [PATCH] Add test for accepting underscores in domain names --- dns/src/strings.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dns/src/strings.rs b/dns/src/strings.rs index 46489e2..d38930d 100644 --- a/dns/src/strings.rs +++ b/dns/src/strings.rs @@ -238,6 +238,18 @@ mod test { Ok((Labels::encode("one.").unwrap(), 5))); } + #[test] + fn one_label_underscore() { + let buf: &[u8] = &[ + 0x03, // label of length 3 + b'_', b'n', b'e', // label + 0x00, // end reading + ]; + + assert_eq!(Cursor::new(buf).read_labels(), + Ok((Labels::encode("_ne.").unwrap(), 5))); + } + #[test] fn two_labels() { let buf: &[u8] = &[