Parsing fix for lines starting with class or TTL

name.   IN SOA  a6.nstld.com. hostmaster.nic.name ....
              IN 7200   NS      j6.nstld.com.
              7200 IN     NS      k6.nstld.com.

Wasn't handled properly
This commit is contained in:
Miek Gieben 2012-02-27 18:48:53 +01:00
parent fd6bdd4bba
commit 0c0b97f72b
2 changed files with 30 additions and 11 deletions

View File

@ -347,9 +347,9 @@ func TestZoneParsing(t *testing.T) {
// name. 3600 IN SOA a6.nstld.com. hostmaster.nic.name. 203362132 300 300 1209600 300
// name. 10800 IN NS g6.nstld.com.
// name. 10800 IN NS h6.nstld.com.
// name. 10800 IN NS j6.nstld.com.
// name. 10800 IN NS k6.nstld.com.
// name. 7200 IN NS h6.nstld.com.
// name. 3600 IN NS j6.nstld.com.
// name. 3600 IN NS k6.nstld.com.
// name. 10800 IN NS l6.nstld.com.
// name. 10800 IN NS a6.nstld.com.
// name. 10800 IN NS c6.nstld.com.
@ -376,10 +376,10 @@ name IN SOA a6.nstld.com. hostmaster.nic.name. (
300 ; minimum (5 minutes)
)
$TTL 10800 ; 3 hours
NS g6.nstld.com.
NS h6.nstld.com.
NS j6.nstld.com.
NS k6.nstld.com.
IN NS g6.nstld.com.
7200 NS h6.nstld.com.
3600 IN NS j6.nstld.com.
IN 3600 NS k6.nstld.com.
NS l6.nstld.com.
NS a6.nstld.com.
NS c6.nstld.com.

View File

@ -199,8 +199,7 @@ func parseZone(r io.Reader, origin, f string, t chan Token, include int) {
st = _EXPECT_DIRORIGIN_BL
case _DIRINCLUDE:
st = _EXPECT_DIRINCLUDE_BL
case _RRTYPE:
// Everthing has been omitted
case _RRTYPE: // Everthing has been omitted, this is the first thing on the line
h.Name = prevName
h.Rrtype, ok = Str_rr[strings.ToUpper(l.token)]
if !ok {
@ -210,9 +209,29 @@ func parseZone(r io.Reader, origin, f string, t chan Token, include int) {
}
}
st = _EXPECT_RDATA
case _CLASS: // First thing on the line is the class
h.Name = prevName
h.Class, ok = Str_class[strings.ToUpper(l.token)]
if !ok {
if h.Class, ok = classToInt(l.token); !ok {
t <- Token{Error: &ParseError{f, "unknown class", l}}
return
}
}
st = _EXPECT_ANY_NOCLASS_BL
case _BLANK:
// Discard, can happen when there is nothing on the
// line except the RR type
case _STRING: // First thing on the is the ttl
if ttl, ok := stringToTtl(l, f); !ok {
t <- Token{Error: &ParseError{f, "not a TTL", l}}
return
} else {
h.Ttl = ttl
defttl = ttl
}
st = _EXPECT_ANY_NOTTL_BL
default:
t <- Token{Error: &ParseError{f, "syntax error at beginning", l}}
return
@ -485,8 +504,7 @@ func zlexer(s *scan, c chan lex) {
break
}
if stri == 0 {
//l.value = _BLANK
//l.token = " "
// Space directly as the beginnin, handled in the grammar
} else if owner {
// If we have a string and its the first, make it an owner
l.value = _OWNER
@ -573,6 +591,7 @@ func zlexer(s *scan, c chan lex) {
stri = 0
// If not in a brace this ends the comment AND the RR
if brace == 0 {
owner = true
owner = true
l.value = _NEWLINE
l.token = "\n"