diff options
| author | Bob Halley <halley@dnspython.org> | 2020-07-28 09:47:39 -0700 |
|---|---|---|
| committer | Bob Halley <halley@dnspython.org> | 2020-07-28 09:47:39 -0700 |
| commit | 4e4943f100b94c6ece05901ba5b814bbc1665c1c (patch) | |
| tree | 9fb02a9f3cfea8c05fbacb34b08c5b2455c4c0cb /dns/message.py | |
| parent | bac7781ea08a63348bd1458a442b2794e742606d (diff) | |
| download | dnspython-4e4943f100b94c6ece05901ba5b814bbc1665c1c.tar.gz | |
Raise NoPreviousName if a text message tries to refer to a previous name but there is none.
Diffstat (limited to 'dns/message.py')
| -rw-r--r-- | dns/message.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/dns/message.py b/dns/message.py index 59e2692..52e3819 100644 --- a/dns/message.py +++ b/dns/message.py @@ -92,6 +92,9 @@ class ChainTooLong(dns.exception.DNSException): class AnswerForNXDOMAIN(dns.exception.DNSException): """The rcode is NXDOMAIN but an answer was found.""" +class NoPreviousName(dns.exception.SyntaxError): + """No previous name was known.""" + class MessageSection(dns.enum.IntEnum): """Message sections""" @@ -1129,6 +1132,8 @@ class _TextReader: self.relativize, self.relativize_to) name = self.last_name + if name is None: + raise NoPreviousName token = self.tok.get() if not token.is_identifier(): raise dns.exception.SyntaxError @@ -1163,6 +1168,8 @@ class _TextReader: self.relativize, self.relativize_to) name = self.last_name + if name is None: + raise NoPreviousName token = self.tok.get() if not token.is_identifier(): raise dns.exception.SyntaxError @@ -1193,6 +1200,8 @@ class _TextReader: token = self.tok.get() if empty and not token.is_eol_or_eof(): raise dns.exception.SyntaxError + if not empty and token.is_eol_or_eof(): + raise dns.exception.UnexpectedEnd if not token.is_eol_or_eof(): self.tok.unget(token) rd = dns.rdata.from_text(rdclass, rdtype, self.tok, |
