From fa03b275d5b4b3d467a1732f2f9c9f6cf591b6a5 Mon Sep 17 00:00:00 2001 From: Curtis Doty Date: Tue, 21 Apr 2026 00:41:39 +0000 Subject: [PATCH] fix: allow any valid DNS label characters in RR file parser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The parser regexes for owner and next-owner names only accepted [a-zA-Z0-9\\_*-], but vis.py can output any printable ASCII in labels. This caused --continue to fail with "invalid file format" on zones containing names like //.com.er. (RFC 2181 ยง11 permits any octet in labels). Relax both regexes to accept any non-whitespace, non-dot character, matching what the writer can produce and the DNS protocol allows. Fixes: https://github.com/anonion0/nsec3map/issues/29 --- n3map/rrtypes/nsec.py | 2 +- n3map/rrtypes/rr.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/n3map/rrtypes/nsec.py b/n3map/rrtypes/nsec.py index dd05ee8..f22c851 100644 --- a/n3map/rrtypes/nsec.py +++ b/n3map/rrtypes/nsec.py @@ -25,7 +25,7 @@ def __str__(self): return '\t'.join((super(NSEC, self).__str__(), "NSEC", str(self.next_owner), ' '.join(self.types))) def parser(): - p_nsec = re.compile(r'^NSEC\s+(([a-zA-Z0-9\\_*-]+\.|\.)+)((\s+[A-Z0-9]+)*)\s*$') + p_nsec = re.compile(r'^NSEC\s+((\S+?\.|\.)+)((\s+[A-Z0-9]+)*)\s*$') rr_parse = rr.parser() def nsec_from_text(s): try: diff --git a/n3map/rrtypes/rr.py b/n3map/rrtypes/rr.py index 14a81b4..85e7433 100644 --- a/n3map/rrtypes/rr.py +++ b/n3map/rrtypes/rr.py @@ -16,7 +16,7 @@ def __str__(self): def parser(): """Returns a parser for a general resource record""" - p = re.compile(r'^(([a-zA-Z0-9\\_*-]+\.)+|\.)\s+([0-9]|[1-9][0-9]*)\s+IN\s+(.*)$') + p = re.compile(r'^(([^\s.]+\.)+|\.)\s+([0-9]|[1-9][0-9]*)\s+IN\s+(.*)$') def rr_from_text(s): m = p.match(s) try: