Refuse to include \s in the JSON output of a TXT record
[dnssec-prover] / src / rr.rs
index 1755685cabb527075526cb8ec14a28d490117c1a..86f5a807e12accf5504243fb1e145871b5775aa7 100644 (file)
--- a/src/rr.rs
+++ b/src/rr.rs
@@ -65,7 +65,7 @@ impl TryFrom<String> for Name {
                        if label.len() > 63 { return Err(()); }
                }
 
-               Ok(Name(s))
+               Ok(Name(s.to_ascii_lowercase()))
        }
 }
 impl TryFrom<&str> for Name {
@@ -247,7 +247,7 @@ impl StaticRecord for Txt {
        fn name(&self) -> &Name { &self.name }
        fn json(&self) -> String {
                if let Ok(s) = core::str::from_utf8(&self.data) {
-                       if s.chars().all(|c| !c.is_control() && c != '"') {
+                       if s.chars().all(|c| !c.is_control() && c != '"' && c != '\\') {
                                return format!("{{\"type\":\"txt\",\"name\":\"{}\",\"contents\":\"{}\"}}", self.name.0, s);
                        }
                }