Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/rdata/rfc1035/txt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,9 @@ impl<Octs> Txt<Octs> {
Octs: AsRef<[u8]>,
{
let len = parser.remaining();
LongRecordData::check_len(len)?;
let text = parser.parse_octets(len)?;
let mut tmp = Parser::from_ref(text.as_ref());
while tmp.remaining() != 0 {
CharStr::skip(&mut tmp)?
}
Txt::check_slice(text.as_ref())
.map_err(|e| ParseError::Form(e.into()))?;
Ok(Txt(text))
}

Expand Down Expand Up @@ -1125,6 +1122,12 @@ mod test {
);
}

#[test]
fn txt_empty_rejected() {
let mut parser = Parser::from_static(b"");
assert!(Txt::<&[u8]>::parse(&mut parser).is_err());
}

#[test]
fn txt_display() {
fn cmp(input: &[u8], output: &str) {
Expand Down
4 changes: 2 additions & 2 deletions test-data/zonefiles/unknown-zero-length.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
origin: example.com.
zonefile: |
example.com. 3600 IN TXT \# 0
example.com. 3600 IN TYPE65534 \# 0
result:
- owner: example.com.
class: IN
ttl: 3600
data: !Unknown
rtype: Txt
rtype: TYPE65534
data: