From 4b228e007f3580b0aeaf0d6b7b70f456be92f7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Sat, 7 Mar 2020 17:10:12 +0100 Subject: [PATCH] DEL (0x7f) character needs to be escaped (not printable) in output --- lib/dnsbox-base/src/records/powerdns_tests.rs | 6 ++++++ lib/dnsbox-base/src/ser/text/quoted.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/dnsbox-base/src/records/powerdns_tests.rs b/lib/dnsbox-base/src/records/powerdns_tests.rs index eea65fd..ba12d06 100644 --- a/lib/dnsbox-base/src/records/powerdns_tests.rs +++ b/lib/dnsbox-base/src/records/powerdns_tests.rs @@ -304,6 +304,12 @@ fn test_TXT() { None, b"\x0e\xc3\x85LAND ISLANDS", ); + check( + types::TXT, + "\"text with DEL in there: \\127\"", + None, + b"\x19text with DEL in there: \x7f", + ); check( types::TXT, "\"\u{00c5}LAND ISLANDS\"", diff --git a/lib/dnsbox-base/src/ser/text/quoted.rs b/lib/dnsbox-base/src/ser/text/quoted.rs index 761b86f..f8ea5a1 100644 --- a/lib/dnsbox-base/src/ser/text/quoted.rs +++ b/lib/dnsbox-base/src/ser/text/quoted.rs @@ -43,7 +43,7 @@ impl<'a> Iterator for EncodeIterator<'a> { } let b = self.data[0]; self.data = &self.data[1..]; - if b < 32 || b > 127 || (self.encode_whitespace && is_ascii_whitespace(b)) { + if b < 32 || b >= 127 || (self.encode_whitespace && is_ascii_whitespace(b)) { // `\ddd` let d1 = b / 100; let d2 = (b / 10) % 10;